Exemplo n.º 1
0
  def __init__(self, infoFileName):
    self.songName      = os.path.basename(os.path.dirname(infoFileName))
    self.fileName      = infoFileName
    self.info          = ConfigParser()
    self._difficulties = None

    try:
      self.info.read(infoFileName)
    except:
      pass
      
    # Read highscores and verify their hashes.
    # There ain't no security like security throught obscurity :)
    self.highScores = {}
    
    scores = self._get("scores", str, "")
    if scores:
      scores = Cerealizer.loads(binascii.unhexlify(scores))
      for difficulty in scores.keys():
        try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for score, stars, name, hash in scores[difficulty.id]:
          if self.getScoreHash(difficulty, score, stars, name) == hash:
            self.addHighscore(difficulty, score, stars, name)
          else:
            Log.warn("Weak hack attempt detected. Better luck next time.")
Exemplo n.º 2
0
Arquivo: Song.py Projeto: twcb/FoF
 def getObfuscatedScores(self):
     s = {}
     for difficulty in self.highScores.keys():
         s[difficulty.id] = [
             (score, stars, name,
              self.getScoreHash(difficulty, score, stars, name))
             for score, stars, name in self.highScores[difficulty]
         ]
     return binascii.hexlify(Cerealizer.dumps(s))
Exemplo n.º 3
0
 def testHash(self):
     # For the record, the worldchart rejects those hashes:
     scoresHash = "63657265616c310a330a646963740a6c6973740a7475706c650a340a"\
                  "6936333834360a69350a7531310a50617363616c4769617264733430"\
                  "0a343839666538656632343239646564373637363835373930303936"\
                  "31323531633136303662373863310a72310a69310a310a72320a72300a"
     scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
     #print scores[1][0][2]
     self.assertEqual(scores[1][0][2], "PascalGiard")
    def testHash(self):
        # For the record, the worldchart used to reject the following 3 hashes...
        # (name strings are UTF8 encoded)
        scoresHash = (
            "63657265616c310a330a646963740a6c6973740a7475706c650a340a"
            "6936333834360a69350a7531310a50617363616c4769617264733430"
            "0a343839666538656632343239646564373637363835373930303936"
            "31323531633136303662373863310a72310a69310a310a72320a72300a"
        )
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        # print scores[1][0][2]
        self.assertEqual(scores[1][0][2], "PascalGiard")
        # scoreExtHash = "63657265616c310a330a646963740a6c6973740a7475706c650a"\
        #               "390a7334300a3438396665386566323432396465643736373638"\
        #               "353739303039363132353163313630366237386369350a693236"\
        #               "310a693237300a6937320a7331310a466f4669582d332e313030"\
        #               "69300a73300a6936333834360a310a72310a69310a310a72320a"\
        #               "72300a"
        # songHash = "6551c0f99efddfd3c5c7ef2d407c81b8e3001a43"

        # Worldchart accepts this one (name string is NOT UTF8 encoded)
        scoresHash = (
            "63657265616c310a330a646963740a6c6973740a7475706c650a340a"
            "693234323032320a69350a73350a417a7a636f7334300a3233336431"
            "37373139653539323066366461373034633432343864646632313930"
            "32323939656438310a72310a69300a310a72320a72300a"
        )
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        self.assertEqual(scores[0][0][2], "Azzco")
        # print scores[0][0] # Shows that name string IS NOT UTF8 encoded

        # Worldchart used to reject this one (name string is UTF8 encoded)
        scoresHash = (
            "63657265616c310a330a646963740a6c6973740a7475706c650a340a"
            "693135313632390a69340a75350a417a7a636f7334300a3661306562"
            "35346438343962613065376464363836396430373966386631316366"
            "61333133633264310a72310a69300a310a72320a72300a"
        )
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        self.assertEqual(scores[0][0][2], "Azzco")
        print scores[0][0]  # Shows that name string IS UTF8 encoded
        print scores[0][0][2]
        score = scores[0][0][0], scores[0][0][1], str(scores[0][0][2]), scores[0][0][3]
        print score
Exemplo n.º 5
0
    def testHash(self):
        # For the record, the worldchart used to reject the following 3 hashes...
        # (name strings are UTF8 encoded)
        scoresHash = "63657265616c310a330a646963740a6c6973740a7475706c650a340a"\
                     "6936333834360a69350a7531310a50617363616c4769617264733430"\
                     "0a343839666538656632343239646564373637363835373930303936"\
                     "31323531633136303662373863310a72310a69310a310a72320a72300a"
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        #print scores[1][0][2]
        self.assertEqual(scores[1][0][2], "PascalGiard")
        #scoreExtHash = "63657265616c310a330a646963740a6c6973740a7475706c650a"\
        #               "390a7334300a3438396665386566323432396465643736373638"\
        #               "353739303039363132353163313630366237386369350a693236"\
        #               "310a693237300a6937320a7331310a466f4669582d332e313030"\
        #               "69300a73300a6936333834360a310a72310a69310a310a72320a"\
        #               "72300a"
        #songHash = "6551c0f99efddfd3c5c7ef2d407c81b8e3001a43"

        # Worldchart accepts this one (name string is NOT UTF8 encoded)
        scoresHash = "63657265616c310a330a646963740a6c6973740a7475706c650a340a"\
                     "693234323032320a69350a73350a417a7a636f7334300a3233336431"\
                     "37373139653539323066366461373034633432343864646632313930"\
                     "32323939656438310a72310a69300a310a72320a72300a"
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        self.assertEqual(scores[0][0][2], "Azzco")
        #print scores[0][0] # Shows that name string IS NOT UTF8 encoded

        # Worldchart used to reject this one (name string is UTF8 encoded)
        scoresHash = "63657265616c310a330a646963740a6c6973740a7475706c650a340a"\
                     "693135313632390a69340a75350a417a7a636f7334300a3661306562"\
                     "35346438343962613065376464363836396430373966386631316366"\
                     "61333133633264310a72310a69300a310a72320a72300a"
        scores = Cerealizer.loads(binascii.unhexlify(scoresHash))
        self.assertEqual(scores[0][0][2], "Azzco")
        print scores[0][0]  # Shows that name string IS UTF8 encoded
        print scores[0][0][2]
        score = scores[0][0][0], scores[0][0][1], str(
            scores[0][0][2]), scores[0][0][3]
        print score
Exemplo n.º 6
0
 def getObfuscatedScoresExt(self, part = parts[GUITAR_PART]):
   s = {}
   if part == parts[GUITAR_PART]:
     highScores = self.highScores
   elif part == parts[RHYTHM_PART]:
     highScores = self.highScoresRhythm
   elif part == parts[BASS_PART]:
     highScores = self.highScoresBass
   elif part == parts[LEAD_PART]:
     highScores = self.highScoresLead
   else:
     highScores = self.highScores
     
   for difficulty in highScores.keys():
     s[difficulty.id] = [(self.getScoreHash(difficulty, score, stars, name), stars) + scores_ext for score, stars, name, scores_ext in highScores[difficulty]]
   return binascii.hexlify(Cerealizer.dumps(s))
Exemplo n.º 7
0
  def __init__(self, infoFileName):
    self.songName      = os.path.basename(os.path.dirname(infoFileName))
    self.fileName      = infoFileName
    self.info          = Config.MyConfigParser()
    self._difficulties = None
    self._parts        = None

    try:
      self.info.read(infoFileName)
    except:
      pass
      
    # Read highscores and verify their hashes.
    # There ain't no security like security throught obscurity :)
    self.highScores = {}
    
    scores = self._get("scores", str, "")
    scores_ext = self._get("scores_ext", str, "")
    if scores:
      scores = Cerealizer.loads(binascii.unhexlify(scores))
      if scores_ext:
        scores_ext = Cerealizer.loads(binascii.unhexlify(scores_ext))
      for difficulty in scores.keys():
        try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for i, base_scores in enumerate(scores[difficulty.id]):
          score, stars, name, hash = base_scores
          if scores_ext != "":
            #Someone may have mixed extended and non extended
            try:
              hash_ext, stars2, notesHit, notesTotal, noteStreak, modVersion, modOptions1, modOptions2 =  scores_ext[difficulty.id][i]
              scoreExt = (notesHit, notesTotal, noteStreak, modVersion, modOptions1, modOptions2)
            except:
              hash_ext = 0
              scoreExt = (0, 0, 0 , "RF-mod", "Default", "Default")
          if self.getScoreHash(difficulty, score, stars, name) == hash:
            if scores_ext != "" and hash == hash_ext:
              self.addHighscore(difficulty, score, stars, name, part = parts[GUITAR_PART], scoreExt = scoreExt)
            else:
              self.addHighscore(difficulty, score, stars, name, part = parts[GUITAR_PART])
          else:
            Log.warn("Weak hack attempt detected. Better luck next time.")

    self.highScoresRhythm = {}
    
    scores = self._get("scores_rhythm", str, "")
    if scores:
      scores = Cerealizer.loads(binascii.unhexlify(scores))
      for difficulty in scores.keys():
        try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for score, stars, name, hash in scores[difficulty.id]:
          if self.getScoreHash(difficulty, score, stars, name) == hash:
            self.addHighscore(difficulty, score, stars, name, part = parts[RHYTHM_PART])
          else:
            Log.warn("Weak hack attempt detected. Better luck next time.")

    self.highScoresBass = {}
    
    scores = self._get("scores_bass", str, "")
    if scores:
      scores = Cerealizer.loads(binascii.unhexlify(scores))
      for difficulty in scores.keys():
        try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for score, stars, name, hash in scores[difficulty.id]:
          if self.getScoreHash(difficulty, score, stars, name) == hash:
            self.addHighscore(difficulty, score, stars, name, part = parts[BASS_PART])
          else:
            Log.warn("Weak hack attempt detected. Better luck next time.")

    self.highScoresLead = {}
    
    scores = self._get("scores_lead", str, "")
    if scores:
      scores = Cerealizer.loads(binascii.unhexlify(scores))
      for difficulty in scores.keys():
        try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for score, stars, name, hash in scores[difficulty.id]:
          if self.getScoreHash(difficulty, score, stars, name) == hash:
            self.addHighscore(difficulty, score, stars, name, part = parts[LEAD_PART])
          else:
            Log.warn("Weak hack attempt detected. Better luck next time.")            
Exemplo n.º 8
0
 def getObfuscatedScores(self):
   s = {}
   for difficulty in self.highScores.keys():
     s[difficulty.id] = [(score, stars, name, self.getScoreHash(difficulty, score, stars, name)) for score, stars, name in self.highScores[difficulty]]
   return binascii.hexlify(Cerealizer.dumps(s))
 def testIntegrity(self):
     expected = self.scores
     scoresSerial = binascii.hexlify(Cerealizer.dumps(self.scores))
     result = Cerealizer.loads(binascii.unhexlify(scoresSerial))
     self.assertEqual(result, expected)
Exemplo n.º 10
0
 def testIntegrity(self):
   expected = self.scores
   scoresSerial = binascii.hexlify(Cerealizer.dumps(self.scores))
   result = Cerealizer.loads(binascii.unhexlify(scoresSerial))
   self.assertEqual(result, expected)
Exemplo n.º 11
0
    self.text = text
    
  def __str__(self):
    return self.text

difficulties = {
  EASY_DIFFICULTY:    Difficulty(EASY_DIFFICULTY,    "Easy"),
  MEDIUM_DIFFICULTY:  Difficulty(MEDIUM_DIFFICULTY,  "Medium"),
  AMAZING_DIFFICULTY: Difficulty(AMAZING_DIFFICULTY, "Amazing"),
}


scores = sys.argv[1]
#scores = "63657265616c310a370a646963740a6c6973740a7475706c650a340a6934393730300a69340a73360a6b65657033727334300a653863646533396538663765613338633033383762346134636266623930646666613763653036657475706c650a340a6934353833360a69340a73360a6b65657033727334300a326130383431356637306263383935333333363539303234643436633361623766376635656530357475706c650a340a6934343735330a69340a73360a6b65657033727334300a616161643338366338636237656330313664316334383133656531643530333434323861343633317475706c650a340a6933353539340a69330a73360a6b65657033727334300a613533343038373636313563393332376531396635613938616534306535303938336563363463637475706c650a340a6933353533360a69330a73360a6b65657033727334300a30626663373635393237343130386236316235323139356464616430666638613664316536323138310a72310a69320a350a72320a72330a72340a72350a72360a72300a"

scores = Cerealizer.loads(binascii.unhexlify(scores))

#print scores

for difficulty in scores.keys():
	try:
          difficulty = difficulties[difficulty]
        except KeyError:
          continue
        for score, stars, name, hash in scores[difficulty.id]:
          print score, stars, name, hash, difficulty.id, "eof"




Exemplo n.º 12
0
def decodify(data):

    try:
        return Cerealizer.loads(data.decode('hex'))
    except:
        return None