On closer inspection, I'm fairly confident the encryption module is wrong. I'm able to decrypt strings I generate, but not those that are generated when I actually play the game.
I'll take a look at it tomorrow and see exactly what's wrong. Here's the new file, I added a decryptString function to verify it wasn't working.
Code:#!/usr/bin/env python import random import re # Neomaster class. class Encryption: aDecimals = [] aHex = [] iHexLen = 0 def __init__( self ): # Let's initialise all of the decimals self.aDecimals.append([42, 75, 83, 53, 102, 74, 40, 43, 44, 61, 70, 79, 36, 86, 94, 101, 108, 67, 106, 112, 76, 98, 69, 95, 64, 81, 59, 126, 45, 57, 71, 125, 56, 122, 105, 66, 85, 103, 49, 99, 41, 109, 72, 107, 121, 80, 87, 100, 48, 65, 120, 110, 88, 55, 50, 73, 77, 113, 89, 52, 111, 119, 78, 63, 118, 33, 116, 46, 54, 117, 68, 123, 115, 104, 37, 97, 38, 84, 82, 58, 90, 114, 51]); self.aDecimals.append([78, 59, 122, 113, 101, 69, 50, 80, 115, 55, 48, 108, 86, 56, 106, 68, 45, 33, 53, 90, 103, 120, 66, 54, 75, 102, 118, 64, 87, 99, 61, 121, 41, 88, 100, 81, 98, 76, 77, 42, 67, 73, 119, 107, 111, 63, 116, 38, 82, 114, 46, 37, 95, 84, 74, 70, 79, 94, 105, 52, 123, 85, 65, 110, 43, 97, 126, 49, 44, 83, 104, 71, 72, 36, 125, 51, 40, 117, 57, 58, 112, 89, 109]); self.aDecimals.append([50, 73, 77, 72, 113, 98, 68, 61, 71, 88, 43, 105, 38, 53, 42, 81, 52, 111, 86, 121, 46, 74, 89, 115, 59, 112, 84, 58, 102, 41, 117, 120, 76, 123, 103, 107, 85, 57, 118, 67, 110, 109, 99, 114, 55, 66, 90, 64, 70, 87, 78, 100, 95, 125, 119, 75, 44, 51, 83, 104, 65, 101, 69, 79, 122, 97, 80, 33, 37, 54, 108, 56, 48, 106, 45, 82, 40, 126, 63, 49, 116, 94, 36]); self.aDecimals.append([109, 97, 54, 51, 118, 43, 81, 104, 57, 113, 74, 53, 100, 83, 42, 102, 103, 116, 48, 82, 117, 72, 36, 115, 71, 119, 41, 59, 87, 95, 122, 52, 108, 45, 98, 73, 86, 66, 111, 78, 126, 80, 69, 123, 40, 70, 120, 38, 121, 64, 58, 56, 37, 112, 110, 84, 107, 50, 90, 101, 125, 33, 89, 49, 55, 99, 67, 75, 114, 85, 105, 106, 79, 61, 94, 65, 77, 63, 44, 46, 88, 68, 76]); self.aDecimals.append([67, 119, 66, 37, 95, 80, 105, 64, 44, 63, 40, 49, 109, 107, 103, 120, 55, 110, 113, 97, 42, 99, 112, 85, 68, 106, 115, 50, 59, 71, 108, 76, 90, 75, 101, 94, 122, 43, 52, 61, 73, 116, 100, 118, 125, 88, 72, 54, 98, 78, 83, 86, 114, 48, 81, 53, 87, 77, 36, 58, 104, 111, 123, 70, 79, 102, 74, 89, 117, 41, 69, 84, 82, 126, 121, 57, 51, 56, 33, 46, 45, 65, 38]); self.aDecimals.append([119, 103, 48, 97, 37, 90, 80, 83, 74, 59, 85, 95, 36, 101, 49, 45, 109, 118, 112, 58, 113, 99, 120, 82, 108, 110, 126, 75, 84, 88, 69, 52, 40, 63, 117, 115, 79, 72, 64, 107, 61, 123, 106, 87, 42, 53, 89, 66, 111, 51, 78, 50, 54, 67, 81, 116, 38, 57, 55, 73, 71, 98, 68, 46, 65, 102, 122, 77, 121, 100, 114, 94, 44, 86, 104, 76, 41, 70, 105, 43, 56, 33, 125]); self.aDecimals.append([37, 106, 79, 117, 78, 99, 107, 44, 101, 109, 40, 81, 86, 122, 72, 45, 110, 68, 114, 56, 33, 98, 71, 63, 111, 102, 104, 75, 89, 100, 125, 65, 115, 50, 53, 66, 82, 36, 74, 38, 119, 84, 112, 126, 105, 70, 48, 85, 42, 57, 94, 59, 76, 118, 43, 46, 80, 87, 58, 95, 73, 108, 88, 103, 123, 90, 97, 41, 113, 64, 67, 69, 54, 83, 61, 116, 52, 49, 51, 55, 77, 120, 121]); self.aDecimals.append([53, 103, 114, 73, 59, 118, 58, 90, 48, 64, 74, 110, 102, 111, 46, 63, 108, 123, 126, 122, 72, 83, 36, 100, 37, 112, 89, 113, 70, 50, 41, 38, 85, 101, 55, 115, 33, 40, 106, 84, 125, 76, 117, 42, 49, 77, 81, 43, 65, 44, 86, 56, 67, 121, 109, 68, 80, 94, 57, 97, 95, 119, 120, 104, 105, 71, 87, 75, 82, 88, 99, 79, 116, 69, 52, 54, 66, 107, 61, 98, 78, 51, 45]); self.aDecimals.append([69, 33, 72, 64, 46, 119, 76, 112, 59, 88, 78, 87, 97, 79, 89, 40, 126, 122, 61, 54, 95, 66, 94, 80, 125, 106, 117, 48, 36, 74, 123, 51, 71, 103, 56, 121, 107, 44, 38, 110, 65, 111, 86, 84, 73, 53, 99, 43, 85, 77, 68, 100, 120, 41, 83, 81, 58, 50, 42, 67, 82, 101, 52, 116, 75, 49, 114, 37, 63, 115, 55, 104, 98, 57, 102, 90, 113, 105, 45, 108, 109, 70, 118]); self.aDecimals.append([68, 103, 43, 113, 80, 84, 76, 44, 63, 45, 71, 72, 59, 123, 106, 75, 56, 86, 105, 41, 126, 120, 37, 111, 54, 97, 102, 50, 58, 94, 117, 67, 73, 66, 74, 78, 119, 115, 99, 65, 85, 90, 40, 89, 107, 114, 101, 77, 64, 57, 118, 69, 82, 49, 110, 88, 36, 122, 98, 95, 121, 79, 109, 81, 51, 38, 52, 108, 87, 70, 100, 83, 53, 48, 33, 61, 104, 42, 112, 46, 55, 116, 125]); self.aDecimals.append([46, 101, 72, 108, 54, 58, 109, 107, 112, 120, 61, 81, 75, 86, 43, 126, 85, 77, 51, 67, 41, 90, 111, 69, 89, 105, 38, 53, 70, 125, 94, 59, 73, 95, 49, 76, 82, 110, 65, 103, 74, 63, 48, 104, 56, 113, 123, 68, 57, 44, 36, 87, 80, 122, 106, 79, 37, 102, 66, 88, 117, 40, 99, 118, 33, 97, 71, 55, 119, 100, 98, 64, 121, 116, 52, 50, 83, 45, 114, 78, 84, 42, 115]); self.aDecimals.append([57, 123, 110, 37, 65, 38, 42, 51, 97, 69, 76, 98, 44, 99, 113, 82, 66, 119, 90, 83, 49, 112, 85, 74, 40, 126, 111, 106, 122, 73, 72, 36, 84, 46, 100, 61, 48, 56, 52, 75, 95, 89, 68, 103, 94, 105, 116, 58, 78, 117, 33, 115, 120, 109, 81, 104, 114, 45, 67, 87, 108, 54, 125, 43, 79, 107, 77, 102, 121, 59, 86, 71, 55, 50, 101, 63, 53, 118, 41, 80, 64, 88, 70]); self.aDecimals.append([40, 43, 123, 125, 97, 109, 126, 56, 48, 113, 107, 121, 73, 102, 118, 94, 33, 106, 89, 50, 46, 88, 67, 63, 112, 75, 64, 51, 114, 95, 104, 68, 58, 100, 74, 72, 70, 111, 117, 87, 37, 78, 55, 71, 105, 54, 81, 59, 86, 41, 44, 57, 49, 69, 116, 80, 98, 110, 119, 82, 76, 101, 122, 42, 85, 79, 45, 77, 103, 61, 83, 108, 65, 120, 90, 115, 53, 66, 52, 84, 36, 38, 99]); self.aDecimals.append([67, 70, 72, 64, 75, 73, 89, 95, 48, 77, 37, 115, 87, 53, 74, 120, 110, 83, 84, 121, 101, 33, 116, 80, 104, 98, 45, 90, 119, 59, 125, 42, 38, 58, 126, 68, 94, 107, 86, 123, 108, 118, 46, 88, 51, 36, 117, 109, 97, 65, 112, 54, 85, 82, 43, 102, 105, 79, 81, 99, 50, 113, 61, 40, 100, 76, 57, 63, 56, 66, 55, 52, 69, 71, 44, 111, 122, 49, 41, 106, 78, 114, 103]); self.aDecimals.append([51, 40, 83, 87, 105, 94, 79, 69, 46, 114, 101, 63, 121, 103, 37, 65, 107, 115, 76, 88, 53, 119, 109, 57, 52, 71, 84, 125, 41, 113, 54, 50, 61, 98, 59, 55, 118, 45, 56, 42, 123, 85, 106, 38, 100, 78, 36, 116, 44, 82, 66, 97, 75, 86, 122, 126, 33, 48, 67, 99, 90, 49, 72, 64, 108, 77, 102, 80, 112, 95, 117, 120, 74, 89, 81, 58, 70, 110, 104, 73, 43, 68, 111]); self.aDecimals.append([99, 87, 114, 64, 77, 78, 115, 83, 111, 48, 72, 75, 73, 121, 112, 56, 105, 94, 76, 36, 42, 65, 85, 45, 116, 74, 61, 54, 103, 84, 89, 67, 57, 43, 80, 86, 113, 117, 120, 119, 95, 81, 55, 69, 125, 33, 107, 109, 41, 58, 70, 90, 106, 52, 118, 97, 102, 51, 79, 37, 101, 53, 104, 40, 82, 122, 126, 88, 110, 71, 66, 98, 108, 100, 49, 63, 44, 46, 68, 50, 59, 123, 38]); self.aDecimals.append([119, 103, 79, 101, 114, 81, 52, 53, 50, 55, 51, 106, 37, 111, 68, 117, 48, 73, 42, 58, 77, 65, 84, 86, 71, 88, 104, 83, 105, 94, 115, 74, 49, 112, 67, 76, 118, 95, 36, 38, 66, 46, 56, 100, 126, 33, 40, 109, 82, 123, 69, 85, 122, 44, 59, 99, 61, 45, 63, 107, 80, 41, 102, 89, 116, 113, 110, 57, 87, 98, 121, 70, 97, 54, 108, 64, 120, 43, 72, 78, 125, 75, 90]); self.aDecimals.append([118, 81, 69, 71, 103, 65, 90, 43, 64, 94, 111, 52, 61, 66, 116, 83, 54, 59, 102, 46, 100, 40, 36, 68, 114, 48, 79, 109, 84, 80, 78, 85, 122, 86, 101, 89, 95, 41, 112, 106, 126, 74, 77, 99, 72, 37, 50, 33, 38, 107, 73, 108, 51, 44, 110, 56, 87, 57, 58, 55, 42, 88, 49, 115, 125, 75, 97, 104, 123, 53, 45, 70, 113, 117, 63, 98, 76, 120, 82, 67, 119, 105, 121]); self.aDecimals.append([44, 87, 37, 57, 52, 120, 82, 36, 125, 115, 70, 105, 59, 86, 94, 111, 46, 117, 99, 42, 84, 68, 38, 102, 109, 121, 48, 55, 122, 78, 41, 112, 107, 101, 45, 58, 66, 74, 77, 116, 51, 119, 73, 126, 56, 64, 69, 81, 76, 106, 61, 110, 85, 33, 53, 118, 95, 114, 123, 90, 65, 40, 54, 113, 108, 97, 50, 104, 72, 98, 103, 88, 79, 43, 67, 63, 89, 100, 49, 75, 83, 80, 71]); self.aDecimals.append([49, 106, 73, 56, 70, 59, 119, 45, 115, 38, 64, 81, 86, 97, 114, 66, 102, 121, 98, 67, 78, 74, 104, 54, 80, 110, 52, 82, 37, 94, 68, 117, 84, 120, 63, 57, 105, 72, 61, 50, 85, 51, 71, 55, 46, 89, 79, 41, 101, 44, 36, 69, 87, 76, 90, 123, 125, 116, 112, 40, 108, 83, 99, 107, 53, 48, 65, 58, 118, 43, 111, 122, 126, 103, 33, 95, 100, 88, 77, 113, 75, 42, 109]); # Let's loop through and convert decimals to their hexidecimal values for eachDecimalList in self.aDecimals: sHex = "" if( isinstance( eachDecimalList, list ) ): for eachDecimal in eachDecimalList: sHex += chr( eachDecimal ) self.aHex.append( sHex ) self.iHexLen = len( self.aHex[0] ) def initBin( self, game_hash, game_sk ): self.sBin = game_hash + game_sk self.iBinLen = len( self.sBin ) def addSlashes( self, s ): hexString = self.string2Hex( s ); return self.escapeString( hexString ); def string2Hex( self, s ): ## Intialise the variables sReplace = "" ii = random.randint( 0, len( self.aDecimals ) - 1 ) sHex = self.aHex[ii]; y = 0 for x in range( len( s ) ): if y >= self.iBinLen: y = 0; sHexChatAt = sHex.find(s[x:x+1]) if sHexChatAt >= 0: sHexChatAt = (sHexChatAt + sHex.find( self.sBin[y:y+1])) % self.iHexLen sReplace = sReplace + sHex[sHexChatAt:sHexChatAt+1] else: sReplace = sReplace + s[x:x+1] y += 1 if ii >= 10: sReplace = sReplace + str( ii ) else: sReplace = sReplace + str( 0 ) + str( ii ) return sReplace def escapeString( self, s ): sReplace = "" for y in range( len( s ) ): sHexChatAt = str( ord( s[y:y+1] ) ) # Make sure the sHexChatAt variable is 3 digits in length (i.e. 9 => 009) while( len( sHexChatAt ) < 3 ): sHexChatAt = "0" + sHexChatAt sReplace = sReplace + sHexChatAt return sReplace def decryptString( self, s ): # Let's fetch all of the decimals matches = re.findall( "(\d{3})", s ) # Find the string c = "" for eachDecimal in matches: c += chr( int( eachDecimal ) ) # What was the random integer we used? ii = int( c[ -2: ] ) # What hex value are we using? sHex = self.aHex[ ii ] # Initialise some variables y = 0 s = "" # Let's loop through to decrypt for x in range( len( c ) - 2 ): z = c[ x:x+1 ] # If we've exceeded the iBinLength let's just set it back to 0 if y >= self.iBinLen: y = 0 sHexChatAt = sHex.find( z ) r = sHex.find( self.sBin[ y:y+1 ] ) # What character are we using? x1 = sHexChatAt - r c1 = sHex[ x1 : x1 + 1 ] s += c1 y += 1 return s """ Generated myself through addSlashes function encrypt = Encryption() encrypt.initBin( "d9da5a9cd17122fc192e", "0487cb8e3a6d30ed4ba9" ) Raw = "057059064106113106033059083079115106076098119059043041040046115055054038068085100118106067041048097089090080076086044079077066045081101090126056055079112108076098064120042083101043103071050066066126105043102125087117094061036101053108066121059103123069038085033086046097110079051038067072106082106065120049056" s = encrypt.decryptString( Raw ) print( s ) Generated by Neopets game: encrypt = Encryption() encrypt.initBin( "2547b6356c154a1b7abb", "3b5610f57912b254d003" ) Raw = "113095106040075061109075121059042097044072057101116090097064072072097045090108110077109073056121081076049064058115052107059051077114072103041075121059095126123072067056049050037041097072077071097061083075077121067059107082105033081107071061061082049073084043109077043037095105033074078072042078090109049050" s = encrypt.decryptString( Raw ) print( s ) """
Results 1 to 23 of 23
Threaded View
- 18 Apr. 2011 01:26pm #7