Advertisement
bnnm

doc_at3_dec.py

Feb 6th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. # ########################################
  2. # Dirge of Cerberus .at3 decryptor
  3. # by bnnm
  4. # ########################################
  5.  
  6. import sys
  7.  
  8. key_size = 0x60
  9. key = [
  10. 0xA3,0xDD,0x51,0x46,0x7C,0x49,0x5B,0x1C,0x81,0x25,0x81,0x55,0x9A,0x6B,0xAF,0xD5,
  11. 0x21,0xF2,0x88,0x3E,0x47,0xDA,0x51,0xE1,0x2F,0x9B,0x81,0xA7,0x1F,0xCB,0x00,0x01,
  12. 0xA5,0x47,0x00,0xAC,0xBF,0x32,0x03,0x44,0xAB,0x44,0x7B,0x9A,0xA8,0xA0,0x4E,0xDF,
  13. 0x06,0x73,0xD1,0x49,0x26,0xCB,0xB4,0xF4,0x0D,0x5F,0x66,0xDF,0x32,0xCA,0xB9,0x27,
  14. 0x98,0x91,0x4D,0x20,0x80,0x6A,0x38,0x60,0x9E,0x79,0xC4,0x8A,0x08,0x07,0xD3,0x87,
  15. 0x23,0xE1,0x28,0xD4,0x20,0xB5,0x52,0xAC,0x35,0x4C,0x45,0x2F,0xF8,0x60,0x8C,0x3A
  16. ]
  17. key_len = len(key)
  18.  
  19. if len(sys.argv) != 2:
  20. print("Infile not specified")
  21. exit()
  22.  
  23. infile_path = sys.argv[1]
  24. outfile_path = infile_path + '.dec'
  25.  
  26. if infile_path.endswith('title.at3'):
  27. print("Infile not encrypted")
  28. exit()
  29.  
  30. infile = open(infile_path, "rb")
  31. outfile = open(outfile_path, "wb+")
  32.  
  33.  
  34. while True:
  35. data = bytearray(infile.read(key_len))
  36. data_len = len(data)
  37. if data_len == 0:
  38. break
  39.  
  40. # decrypt
  41. for i in range(0, data_len):
  42. # base key xor
  43. data[i] = data[i] ^ key[i]
  44. # re-xor with all the values 0x10 above
  45. for j in range(0, i/0x10):
  46. data[i] = data[i] ^ data[i - (j+1)*0x10]
  47.  
  48. outfile.write(data)
  49.  
  50.  
  51. infile.close()
  52. outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement