Guest User

DragonQuest_XI.bms

a guest
Sep 10th, 2018
1,596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Unreal Engine 4 - Unreal Tournament 4 (*WindowsNoEditor.pak) (script 0.4.20a)
  2. # script for QuickBMS http://quickbms.aluigi.org
  3. # Modded to work with Dragon Quest XI by infogram :)
  4.  
  5. math NO_TAIL_INFO = 0 # set it to 1 for archives with corrupt/missing tail information
  6.  
  7. quickbmsver "0.8.4"
  8.  
  9. math TOC_FILE = 0
  10.  
  11. # set your AES_KEY here as text or C string ("\x11\x22...") or umodel hex (0x1122...)
  12. set AES_KEY binary "JACK-NE-KEY-1QaZ2WsX3EdC4RfV5TgB"
  13. putarray 10 -1 "KIWIKIWIKIWIKIWIKIWIKIWIKIWIKIWI" # first beta of Street Fighter V
  14. putarray 10 -1 "_aS4mfZK8M5s5KWC2Lz2VsFnGKI7azgl" # current version of Street Fighter V
  15. putarray 10 -1 "bR!@nbR0wnc@rychR!$d@nd@v3d3R3kj!mj0$hk3v!nm!ch@3lm!k3s3@nst3v3t!m" # Victory: The Culling
  16. putarray 10 -1 "casd#55@#$%323!$^#b%05sa5W|hhaf4365s52ss51|55m!|{55s^@@36f233|-|0w@%3g8hssDk35/!Nm|_|%ds23%a32d5&23as3%12p|-|y$t3ds562d23fav3c@dyw38#49" # Victory: The Culling
  17. putarray 10 -1 "C8C4847F3B4FA52D4AAD57A52358CDBC" # Injustice 2 (iOS)
  18. putarray 10 -1 "k14z0ZLR8a7jNm49uyBzxXYY9LpTHcehLSNiC3jAkzBsffPuy8YsTa72RLD9KWIn" # Gal*Gun VR
  19. putarray 10 -1 "E7@[dZfoYCW;+YWR;0JK^{9tt:yU0_T&" # Marvel VS Capcom - Infinite
  20. putarray 10 -1 "E1A1F2E4AA066C54BD5090F463EDDF58D01684243672B3CE809FF47FF473B04A" # OverHit
  21. putarray 10 -1 "I0vV6wr0TFbg3m23QuSIwnYC1sI0AIDq" # Fernbus
  22. putarray 10 -1 "y298qjSb115NqQ3Agad30DWn2QYrTI8CT6aP05l2PBV9Qe92S94PdoVCCy06A38L" # Fortnite
  23. putarray 10 -1 "b9uW0RKNY91be8HN3Lemi68j6Xsi2l7fQJYsp5oR4al4C4c9kY5E0l90411l9P3L" # Dragonball FighterZ
  24. putarray 10 -1 "45DD15D6DD2DA50AEB71CE7A5284CF8EA498B2EC3D52B7E336F3EA0071CE44B3"
  25. putarray 10 -1 "MRZpemumg6t2AXExrMQs6TSoZRG+YSABK338oc6F8kTXu4k6QffJgYAzKl65Tk2L"
  26. putarray 10 -1 "0x9D8C9A4A4FA082F213EED604B6E756237181685EEDA82216437617D7AA5231AF"
  27. putarray 10 -1 ""
  28. math AES_KEY_IS_SET = 0
  29.  
  30. math ALTERNATIVE_MODE = 0
  31.  
  32. get ARCHIVE_NAME basename
  33. get ARCHIVE_PATH FILEPATH
  34.  
  35. math VERSION = 0
  36.  
  37. math CHUNK_OFFSET_ABSOLUTE = -1 # default, enabled
  38.  
  39. # 1 = HIT
  40. math WORKAROUND = 0
  41.  
  42. if NO_TAIL_INFO != 0
  43. get OFFSET asize
  44. math ALTERNATIVE_MODE = 1
  45. else
  46. goto -0x2c
  47. get MAGIC long #idstring "\xe1\x12\x6f\x5a" # 0x5a6f12e1
  48. endian guess MAGIC # 0x5a6f12e1:le, 0xe1126f5a:be
  49. if MAGIC == 0x1233a # HIT game
  50. math WORKAROUND = 1
  51. elif MAGIC == 0x1066a # OverHit
  52. math WORKAROUND = 1
  53. elif MAGIC == 0x13aed # OverHit
  54. math WORKAROUND = 1
  55. elif ARCHIVE_NAME & "OverHit"
  56. math WORKAROUND = 1
  57. elif ARCHIVE_NAME == "0" # HIT
  58. math WORKAROUND = 1
  59. elif ARCHIVE_PATH & "Gears of War 4"
  60. math WORKAROUND = 2
  61. endif
  62. get VERSION long
  63. get OFFSET longlong
  64. get SIZE longlong
  65. getdstring HASH 20
  66. if WORKAROUND == 1
  67. math VERSION = 3
  68. endif
  69.  
  70. if VERSION >= 3
  71. goto -0x2d
  72. get ENCRYPTED byte
  73. if ENCRYPTED != 0
  74. callfunction SET_AES_KEY 1
  75. log MEMORY_FILE10 OFFSET SIZE
  76. encryption "" ""
  77. math TOC_FILE = -10 # MEMORY_FILE10 is -10
  78. endif
  79. endif
  80.  
  81. goto OFFSET # don't use TOC_FILE
  82. callfunction GET_NAME 1
  83. endif
  84.  
  85. if ALTERNATIVE_MODE == 0
  86. get FILES long TOC_FILE
  87. else
  88. math FILES = 0x7fffffff
  89. math MAX_OFF = OFFSET
  90. goto 0
  91. set NAME string ""
  92. endif
  93.  
  94. math CHUNK_SIZE = 0x10000 # just in case...
  95. for i = 0 < FILES
  96. if ALTERNATIVE_MODE == 0
  97. callfunction GET_NAME 1
  98. if NAMESZ == 0 # lame work-around for Conan Exiles
  99. callfunction GET_NAME 1
  100. endif
  101. endif
  102. savepos TMP_OFF # no need to use TOC_FILE in savepos/goto
  103.  
  104. get OFFSET longlong TOC_FILE
  105. if WORKAROUND == 2
  106. get ZSIZE long TOC_FILE
  107. get SIZE long TOC_FILE
  108. get ZIP byte TOC_FILE
  109. else
  110. get ZSIZE longlong TOC_FILE
  111. get SIZE longlong TOC_FILE
  112. get ZIP long TOC_FILE
  113. endif
  114. if WORKAROUND == 1
  115. getdstring HASH 20 TOC_FILE
  116. elif VERSION <= 1
  117. get TSTAMP longlong TOC_FILE
  118. endif
  119. if WORKAROUND == 2
  120. else
  121. getdstring HASH 20 TOC_FILE
  122. endif
  123. math CHUNKS = 0
  124. math ENCRYPTED = 1
  125. if VERSION >= 3
  126. if ZIP != 0
  127. get CHUNKS long TOC_FILE
  128. for x = 0 < CHUNKS
  129. get CHUNK_OFFSET longlong TOC_FILE
  130. get CHUNK_END_OFFSET longlong TOC_FILE
  131. putarray 0 x CHUNK_OFFSET
  132. putarray 1 x CHUNK_END_OFFSET
  133. next x
  134. endif
  135. if WORKAROUND == 2
  136. else
  137. get ENCRYPTED byte TOC_FILE
  138. endif
  139. get CHUNK_SIZE long TOC_FILE
  140. endif
  141. math ENCRYPTED = 0
  142. if WORKAROUND == 1
  143. if ARCHIVE_NAME == "0" # HIT game only!
  144. math ENCRYPTED = 0
  145. endif
  146. endif
  147. if ALTERNATIVE_MODE != 0
  148. savepos TMP_OFF
  149. math OFFSET + TMP_OFF
  150. endif
  151.  
  152. comtype copy # for AES
  153. if ZIP & 1
  154. comtype zlib
  155. elif ZIP & 2
  156. comtype gzip
  157. elif ZIP & 4
  158. comtype snappy
  159. if VERSION >= 6
  160. comtype oodle
  161. endif
  162. if WORKAROUND == 2
  163. comtype lz4
  164. endif
  165. elif ZIP & 0x10
  166. comtype oodle
  167. endif
  168. if ZIP == 3 # JoyfunRPG / Faith of Danschant
  169. comtype oodle
  170. endif
  171.  
  172. if CHUNKS > 0
  173. log NAME 0 0
  174. append
  175. math TMP_SIZE = SIZE
  176. if CHUNK_OFFSET_ABSOLUTE < 0 && OFFSET != 0
  177. getarray CHUNK_OFFSET 0 0
  178. if CHUNK_OFFSET u< OFFSET
  179. math CHUNK_OFFSET_ABSOLUTE = 0
  180. else
  181. math CHUNK_OFFSET_ABSOLUTE = 1
  182. endif
  183. endif
  184. for x = 0 < CHUNKS
  185. getarray CHUNK_OFFSET 0 x
  186. getarray CHUNK_END_OFFSET 1 x
  187. math CHUNK_ZSIZE = CHUNK_END_OFFSET
  188. math CHUNK_ZSIZE - CHUNK_OFFSET
  189. if ENCRYPTED != 0
  190. callfunction SET_AES_KEY 1
  191. math CHUNK_ZSIZE x 16
  192. endif
  193.  
  194. if TMP_SIZE u< CHUNK_SIZE
  195. math CHUNK_SIZE = TMP_SIZE
  196. endif
  197. if CHUNK_OFFSET_ABSOLUTE == 0
  198. math CHUNK_OFFSET + OFFSET
  199. endif
  200.  
  201. # DQXI: data gets XOR'd with DEADFADEBEEFCAFE, then NOT'd (in other words, XOR'd with 0xFF)
  202. # so we do it in reverse: NOT the data we read, then XOR with DEADFADE
  203. # do this by telling QBMS to XOR all files reads using "filexor", then tell it to XOR writes using "encryption xor"
  204. # so it'll: read -> filexor -> encryptionxor -> write
  205.  
  206. filexor 0xFF
  207. encryption xor "\xDE\xAD\xFA\xDE\xBE\xEF\xCA\xFE"
  208.  
  209. clog NAME CHUNK_OFFSET CHUNK_ZSIZE CHUNK_SIZE
  210.  
  211. filexor "" # disable filexor
  212.  
  213. math TMP_SIZE - CHUNK_SIZE
  214. next x
  215. append
  216. else
  217. # the file offset points to an entry containing
  218. # the "same" OFFSET ZSIZE SIZE ZIP HASH ZERO fields,
  219. # just an additional backup... so let's skip them
  220. savepos BASE_OFF
  221. math BASE_OFF - TMP_OFF
  222. math OFFSET + BASE_OFF
  223. if ENCRYPTED != 0
  224. callfunction SET_AES_KEY 1
  225. math ZSIZE x 16
  226. endif
  227. clog NAME OFFSET ZSIZE SIZE
  228. endif
  229. encryption "" ""
  230.  
  231. if ALTERNATIVE_MODE != 0
  232. math OFFSET + ZSIZE
  233. goto OFFSET
  234. if OFFSET == MAX_OFF
  235. break
  236. endif
  237. if VERSION >= 4
  238. padding 0x800 # necessary for WitchIt
  239. endif
  240. endif
  241. next i
  242.  
  243. startfunction SET_AES_KEY_ASK
  244. math AES_KEY_IS_SET = 1
  245. print "The archive is encrypted, select the number of the key to use or type yours:"
  246. for z = 0
  247. getarray KEY 10 z
  248. if KEY == ""
  249. break
  250. endif
  251. print "%z%: %KEY%"
  252. next z
  253. print "%z%: press RETURN for no encryption (Lineage 2 Revolution)"
  254. set KEY unknown "???"
  255. strlen TMP KEY
  256. if KEY == ""
  257. math AES_KEY_IS_SET = -1
  258. set AES_KEY string "no key, encryption disabled"
  259. elif TMP <= 2
  260. getarray AES_KEY 10 KEY
  261. if AES_KEY strncmp "0x"
  262. string AES_KEY << 2
  263. string AES_KEY h AES_KEY
  264. endif
  265. elif KEY strncmp "0x"
  266. string KEY << 2
  267. string AES_KEY h KEY
  268. else
  269. set AES_KEY binary KEY
  270. endif
  271. print "KEY: %AES_KEY%"
  272. endfunction
  273.  
  274. startfunction SET_AES_KEY
  275. if AES_KEY_IS_SET == 0
  276. callfunction SET_AES_KEY_ASK 1
  277. endif
  278. if AES_KEY_IS_SET > 0
  279. encryption aes AES_KEY "" 0 32
  280. endif
  281. endfunction
  282.  
  283. startfunction GET_NAME
  284. get NAMESZ signed_long TOC_FILE
  285.  
  286. if NAMESZ >= 0
  287. if NAMESZ > 0x200
  288. math ALTERNATIVE_MODE = 1
  289. else
  290. getdstring NAME NAMESZ TOC_FILE
  291. endif
  292. else
  293. math NAMESZ n NAMESZ
  294. if NAMESZ > 0x200
  295. math ALTERNATIVE_MODE = 1
  296. else
  297. math NAMESZ * 2
  298.  
  299. # DQXI: filename xor key is DEADFADEBEEFCAFE, 0x00 spaces between the key because only the upper byte of the unicode char gets xor'd
  300. filexor "0xDE 0x00 0xAD 0x00 0xFA 0x00 0xDE 0x00 0xBE 0x00 0xEF 0x00 0xCA 0x00 0xFE 0x00"
  301.  
  302. getdstring NAME NAMESZ TOC_FILE
  303. set NAME unicode NAME
  304.  
  305. string NAME - 2 # DQXI: after XORing an extra gibberish char is added, this'll remove it
  306. filexor ""
  307. endif
  308. endif
  309. endfunction
RAW Paste Data