Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. # coding=utf-8
  2.  
  3. import os
  4. import zlib
  5. import hashlib
  6.  
  7. ##### MAGIC STUFF FOR GODNOTA DETECTION #####
  8. aiMagicDust4tw = "anivisa3-win" #","
  9. aiMagicDust4tf = "anivisa3-fail" #","
  10.  
  11. def md5(fname):
  12. hash_md5 = hashlib.md5()
  13. with open(fname, "rb") as f:
  14. for chunk in iter(lambda: f.read(4096), b""):
  15. hash_md5.update(chunk)
  16. return hash_md5.hexdigest()
  17.  
  18. def detectGodnotaWithSalt(magicDust,contestItems):
  19. md5winarray = sorted(contestItems, key=str.lower, reverse=False)
  20. md5winhash = magicDust.join(md5winarray)
  21. md5wincrc = zlib.crc32(md5winhash)
  22. win_index = md5wincrc%len(contestItems)
  23. win_item = md5winarray[win_index]
  24. return win_item
  25.  
  26. md5map = {}
  27. md5array = []
  28.  
  29. print("Reading novells...")
  30. for file in os.listdir("./"):
  31. if str.lower(file).endswith(".zip") or str.lower(file).endswith(".rar") or str.lower(file).endswith(".exe"):
  32. file_hash = md5("./"+file)
  33. md5map[file_hash] = file
  34. md5array.append(file_hash)
  35. print(file + ": " + file_hash)
  36.  
  37. print("Calculating ratings of "+ str(len(md5array)) +" novells...")
  38. win_md5 = detectGodnotaWithSalt(aiMagicDust4tw,md5array)
  39. fail_md5 = detectGodnotaWithSalt(aiMagicDust4tf,md5array)
  40.  
  41. print("Done! Contest results:")
  42. print("Anon-win: magic dust="+aiMagicDust4tw+", winner hash="+win_md5+", file="+md5map[win_md5])
  43. print("Anon-fail: magic dust="+aiMagicDust4tf+", looser hash="+fail_md5+", file="+md5map[fail_md5])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement