Advertisement
xzlui

Jet's R3D Apple Resigner Source Code

Feb 17th, 2024
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 12.12 KB | None | 0 0
  1. REM This tool was created by Jet for the purpose of decompiling/recompiling EBOOT.BIN/.ELF files for PlayStation 3 games.
  2. REM I am releasing this code with full authorization for the purpose of education.
  3.  
  4. @shift /0
  5. @shift
  6. @echo off
  7. call data\config
  8. setlocal enabledelayedexpansion
  9. ::pushd %temp%
  10. color 0c
  11. set mode=%fw%
  12. title R3D Apple Resigner 2.1.1 [%mode% Mode]
  13. goto globals
  14.  
  15. :globals
  16. cls
  17. set sid=%random%
  18. set user=%usr%
  19. set curdir=%cd%
  20. set selfctrlflags=4000000000000000000000000000000000000000000000000000000000000002
  21. set selfcapflags=00000000000000000000000000000000000000000000003B0000000100040000
  22. set output=4xxstd
  23. set outputmsg=[4.XX STD]
  24. set elfsdk=41
  25. set keyrev=1C
  26. set fwver=0004002000000000
  27. set ctrlflagswitch=FALSE
  28. set capflagswitch=FALSE
  29. set compress=TRUE
  30. set compressmsg=[ON]
  31. goto init
  32.  
  33. :init
  34. cls
  35. set selfctrlflags=4000000000000000000000000000000000000000000000000000000000000002
  36. set selfcapflags=00000000000000000000000000000000000000000000003B0000000100040000
  37. set output=4xxstd
  38. set outputmsg=[4.XX STD]
  39. set elfsdk=41
  40. set keyrev=1C
  41. set fwver=0004002000000000
  42. set ctrlflagswitch=FALSE
  43. set capflagswitch=FALSE
  44. set compress=TRUE
  45. set compressmsg=[ON]
  46. goto default_mode
  47.  
  48. :default_mode
  49. cls
  50. if %mode%==DEX goto dex_menu
  51. if %mode%==CEX goto cex_menu
  52.  
  53. :dex_menu
  54. if %mode%==CEX goto cex_menu
  55. set mode=DEX
  56. title R3D Apple Resigner 2.1.1 [%mode% Mode]
  57. set opt=NULL
  58. cls
  59. echo WARNING: Be sure that your BIN/ELF is in %cd%
  60. echo.
  61. echo Mode: %mode% // Output: %outputmsg%
  62. echo Type "/cex" to change to CEX mode.
  63. echo.
  64. echo ^+================================^+
  65. ::echo ^|    R3D Apple Resigner 2.1.1    ^|
  66. echo ^|                 .:'            ^|
  67. echo ^|             __ :'__            ^|
  68. echo ^|          .'^`__^`-'__^`^`.         ^|
  69. echo ^|         ^:____R3D___.-'         ^|
  70. echo ^|         ^:__Apple__:            ^|
  71. echo ^|          ^:__2.1.1__`-;         ^|
  72. echo ^|           ^`.__.-.__.'          ^|
  73. echo ^+================================^+
  74. echo ^|    [1] - Decrypt BIN to ELF    ^|
  75. echo ^|    [2] - Resign NON-DRM        ^|
  76. echo ^|    [3] - Output Option         ^|
  77. echo ^|    [4] - Credits               ^|
  78. echo ^|    [5] - About R3D Apple       ^|
  79. echo ^|    [6] - Exit R3D Apple        ^|
  80. echo ^+================================^+
  81. echo.
  82. set /p opt= %user%@%sid%:
  83. if %opt%==1 (goto d_dex)
  84. if %opt%==2 (goto disc_dex)
  85. if %opt%==3 (goto outputoption)
  86. if %opt%==4 (goto credits)
  87. if %opt%==5 (goto about)
  88. if %opt%==6 exit
  89. if %opt%==/dex goto error
  90. if %opt%==/DEX goto error
  91. if %opt%==/cex goto change_mode
  92. if %opt%==/CEX goto change_mode
  93. if not %opt%==1 goto error
  94. if not %opt%==2 goto error
  95. if not %opt%==3 goto error
  96. if not %opt%==4 goto error
  97. if not %opt%==5 goto error
  98. if not %opt%==6 goto error
  99. if not %opt%==/cex goto error
  100. if not %opt%==/CEX goto error
  101.  
  102. :cex_menu
  103. if %mode%==DEX goto dex_menu
  104. set mode=CEX
  105. title R3D Apple Resigner 2.1.1 [%mode% Mode]
  106. set opt=NULL
  107. cls
  108. echo WARNING: Be sure that your BIN/ELF is in %cd%
  109. echo.
  110. echo Mode: %mode% // Output: %outputmsg%
  111. echo Type "/dex" to change to DEX mode.
  112. echo.
  113. echo ^+================================^+
  114. ::echo ^|    R3D Apple Resigner 2.1.1    ^|
  115. echo ^|                 .:'            ^|
  116. echo ^|             __ :'__            ^|
  117. echo ^|          .'^`__^`-'__^`^`.         ^|
  118. echo ^|         ^:____R3D___.-'         ^|
  119. echo ^|         ^:__Apple__:            ^|
  120. echo ^|          ^:__2.1.1__`-;         ^|
  121. echo ^|           ^`.__.-.__.'          ^|
  122. echo ^+================================^+
  123. echo ^|    [1] - Decrypt BIN to ELF    ^|
  124. echo ^|    [2] - Resign NON-DRM        ^|
  125. echo ^|    [3] - Output Option         ^|
  126. echo ^|    [4] - Credits               ^|
  127. echo ^|    [5] - About R3D Apple       ^|
  128. echo ^|    [6] - Exit R3D Apple        ^|
  129. echo ^+================================^+
  130. echo.
  131. set /p opt= %user%@%sid%:
  132. if %opt%==1 (goto d_cex)
  133. if %opt%==2 (goto disc_cex)
  134. if %opt%==3 (goto outputoption)
  135. if %opt%==4 (goto credits)
  136. if %opt%==5 (goto about)
  137. if %opt%==6 exit
  138. if %opt%==/cex goto error
  139. if %opt%==/CEX goto error
  140. if %opt%==/dex goto change_mode
  141. if %opt%==/DEX goto change_mode
  142. if not %opt%==1 goto error
  143. if not %opt%==2 goto error
  144. if not %opt%==3 goto error
  145. if not %opt%==4 goto error
  146. if not %opt%==5 goto error
  147. if not %opt%==6 goto error
  148. if not %opt%==/dex goto error
  149. if not %opt%==/DEX goto error
  150. if %opt%==NULL (goto cex_menu)
  151.  
  152. :d_cex
  153. data\sfk.exe list . .bin>data\list.txt
  154. cls
  155. set /a count=0
  156. for /f %%f in (data\list.txt) do (
  157. set /a count+=1
  158. set a!count!=%%f
  159. if count NEQ 0 (echo  [!count!] %%f )
  160. )
  161. ) else (echo Could not find .BINs to list.)
  162. set filesel=NONE
  163. echo.
  164. echo Type "/q" to quit decryption.
  165. echo.
  166. set /p filesel=[^^!] Enter # to File:
  167. echo.
  168. if %filesel%==/q (goto cex_menu)
  169. if %filesel%==/Q (goto cex_menu)
  170. if %filesel% GTR !count! (
  171. echo [^^!] Invalid Input.
  172. ping localhost -n 3 >nul
  173. goto d_cex
  174. )
  175. if %filesel% LSS 1 (
  176. echo [^^!] Invalid Input.
  177. ping localhost -n 3 >nul
  178. goto d_cex
  179. )
  180. set filename=!a%filesel%!
  181. set file=%filename:~0,-4%
  182.  
  183. if exist %file%.ELF (del %file%.ELF)
  184. echo [*] Decrypting %file%.BIN...
  185. data\scetool.exe --decrypt "%curdir%\%file%.BIN" "%curdir%\%file%.ELF">nul
  186. if exist %file%.ELF (
  187. echo [*] Decrypted to %file%.ELF
  188. ) else (
  189. echo [^^!] Decryption failed.
  190. )
  191. if exist data\list.txt (del data\list.txt)
  192. ping localhost -n 3 >nul
  193. goto cex_menu
  194.  
  195.  
  196. :disc_cex
  197. data\sfk.exe list -file .elf>data\list.txt
  198. cls
  199. set /a count=0
  200. for /f %%f in (data\list.txt) do (
  201. set /a count+=1
  202. set a!count!=%%f
  203. if count NEQ 0 (echo  [!count!] %%f )
  204. )
  205. ) else (echo Could not find .ELFs to list.)
  206. set filesel=NONE
  207. echo.
  208. echo Type "/q" to quit encryption.
  209. echo.
  210. set /p filesel=[^^!] Enter # to File:
  211. echo.
  212. if %filesel%==/Q (goto cex_menu)
  213. if %filesel%==/q (goto cex_menu)
  214. if %filesel% GTR !count! (
  215. echo [^^!] Invalid Input.
  216. ping localhost -n 3 >nul
  217. goto disc_cex
  218. )
  219. if %filesel% LSS 1 (
  220. echo [^^!] Invalid Input.
  221. ping localhost -n 3 >nul
  222. goto disc_cex
  223. )
  224. set filename=!a%filesel%!
  225. set file=%filename:~0,-4%
  226.  
  227. set CID=
  228. FOR /F "tokens=1,2 delims= " %%A IN ('data\scetool.exe -i "%curdir%\%file%.BIN"') DO (
  229. if [%%A]==[ContentID] set CID=%%B
  230. )
  231. data\FixELF.exe %file%.ELF %elfsdk%
  232. if [%CID%]==[] (
  233. data\scetool.exe -v --sce-type=SELF --compress-data=FALSE --skip-sections=TRUE --key-revision=%keyrev% --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-type=APP --self-app-version=0001000000000000 --self-fw-version=%fwver% --encrypt "%curdir%\%file%.ELF" "%curdir%\%file%.BIN" >nul
  234. echo [*] Encrypted to %file%.BIN. ) ELSE (
  235. echo ContentID = %CID%
  236. data\scetool.exe -v --sce-type=SELF --compress-data=FALSE --skip-sections=TRUE --key-revision=%keyrev% --self-auth-id=1010000001000003 --self-add-shdrs=TRUE --self-vendor-id=01000002 --self-type=NPDRM --self-app-version=0001000000000000 --self-fw-version=%fwver% --np-license-type=FREE --np-content-id=%CID% --np-app-type=EXEC --np-real-file=%file%.BIN --encrypt "%curdir%\%file%.ELF" "%curdir%\%file%.BIN" >nul
  237. echo [*] Encrypted to %file%.BIN. )
  238. ::del "%curdir%\%file%.BIN.BAK">nul
  239. ping localhost -n 3 >nul
  240. goto cex_menu
  241.  
  242. :d_dex
  243. data\sfk.exe list -file .bin>data\list.txt
  244. cls
  245. set /a count=0
  246. for /f %%f in (data\list.txt) do (
  247. set /a count+=1
  248. set a!count!=%%f
  249. if count NEQ 0 (echo  [!count!] %%f )
  250. )
  251. ) else (echo Could not find .ELFs to list.)
  252. set filesel=NONE
  253. echo.
  254. echo Type "/q" to quit decryption.
  255. echo.
  256. set /p filesel=[^^!] Enter # to File:
  257. echo.
  258. if %filesel%==/Q (goto dex_menu)
  259. if %filesel%==/q (goto dex_menu)
  260. if %filesel% GTR !count! (
  261. echo [^^!] Invalid Input.
  262. ping localhost -n 3 >nul
  263. goto disc_cex
  264. )
  265. if %filesel% LSS 1 (
  266. echo [^^!] Invalid Input.
  267. ping localhost -n 3 >nul
  268. goto disc_cex
  269. )
  270. set filename=!a%filesel%!
  271. set file=%filename:~0,-4%
  272.  
  273. if not exist %file%.BIN (
  274. echo [^^!] %file%.BIN can't be found.
  275. ping localhost -n 3 >nul
  276. goto dex_menu
  277. )
  278. if exist %file%.ELF (del %file%.ELF)
  279. echo [*] Decrypting %file%.BIN...
  280. data\unfself "%curdir%\%file%.BIN" "%curdir%\%file%.ELF">nul
  281. if exist %file%.ELF (
  282. echo [*] Decrypted to %file%.ELF
  283. ) else (
  284. echo [^^!] Decryption failed.
  285. )
  286. ping localhost -n 3 >nul
  287. goto dex_menu
  288.  
  289. :disc_dex
  290. data\sfk.exe list -file .elf>data\list.txt
  291. cls
  292. set /a count=0
  293. for /f %%f in (data\list.txt) do (
  294. set /a count+=1
  295. set a!count!=%%f
  296. if count NEQ 0 (echo  [!count!] %%f )
  297. )
  298. ) else (echo Could not find .ELFs to list.)
  299. set filesel=NONE
  300. echo.
  301. echo Type "/q" to quit encryption.
  302. echo.
  303. set /p filesel=[^^!] Enter # to File:
  304. echo.
  305. if %filesel%==/Q (goto dex_menu)
  306. if %filesel%==/q (goto dex_menu)
  307. if %filesel% GTR !count! (
  308. echo [^^!] Invalid Input.
  309. ping localhost -n 3 >nul
  310. goto disc_cex
  311. )
  312. if %filesel% LSS 1 (
  313. echo [^^!] Invalid Input.
  314. ping localhost -n 3 >nul
  315. goto disc_cex
  316. )
  317. set filename=!a%filesel%!
  318. set file=%filename:~0,-4%
  319.  
  320. set autoresign=FALSE
  321. if not exist %file%.BIN (
  322. if not exist %file%.ELF (
  323. echo [^^!] %file%.BIN/ELF can't be found.
  324. ping localhost -n 3 >nul
  325. goto dex_menu
  326. )
  327. )
  328. if not exist %file%.ELF (
  329. echo [*] Decrypting %file%.BIN...
  330. data\scetool.exe --decrypt "%curdir%\%file%.BIN" "%curdir%\%file%.ELF">nul
  331. set autoresign=TRUE
  332. )
  333. if not exist %file%.ELF (
  334. echo [^^!] Decryption failed.
  335. ping localhost -n 3 >nul
  336. goto dex_menu
  337. )
  338. if exist %file%.BIN (
  339. if exist %file%.BIN.BAK (del %file%.BIN.BAK)
  340. ren %file%.BIN %file%.BIN.BAK
  341. )
  342. echo [*] Patching %file%.ELF...
  343. data\FixELF "%curdir%\%file%.ELF"
  344. echo [*] Encrypting %file%.ELF...
  345. data\make_fself "%curdir%\%file%.ELF" "%curdir%\%file%.BIN">nul
  346. if %autoresign%==TRUE (del %file%.ELF)
  347. echo [*] Encrypted to %file%.BIN
  348. del %file%.BIN.BAK>nul
  349. ping localhost -n 3 >nul
  350. goto dex_menu
  351.  
  352. :outputoption
  353. if %output%==4xxstd (
  354. set output=4xxalt
  355. set outputmsg=[4.XX ALT]
  356. set elfsdk=41
  357. set keyrev=1C
  358. set fwver=0004002000000000
  359. set ctrlflagswitch=TRUE
  360. set capflagswitch=FALSE
  361. echo.
  362. echo [*] Output set to 4.XX ALT.
  363. ping localhost -n 2 >nul
  364. goto default_mode
  365. )
  366. if %output%==4xxalt (
  367. set output=4xxode
  368. set outputmsg=[4.XX ODE]
  369. set elfsdk=33
  370. set keyrev=0A
  371. set fwver=0003005500000000
  372. set ctrlflagswitch=FALSE
  373. set capflagswitch=TRUE
  374. echo.
  375. echo [*] Output set to 4.XX ODE.
  376. ping localhost -n 2 >nul
  377. goto default_mode
  378. )
  379. if %output%==4xxode (
  380. set output=3xxstd
  381. set outputmsg=[3.XX STD]
  382. set elfsdk=33
  383. set keyrev=04
  384. set fwver=0003004000000000
  385. set ctrlflagswitch=FALSE
  386. set capflagswitch=FALSE
  387. echo.
  388. echo [*] Output set to 3.XX STD.
  389. ping localhost -n 2 >nul
  390. goto default_mode
  391. )
  392. if %output%==3xxstd (
  393. set output=3xxalt
  394. set outputmsg=[3.XX ALT]
  395. set elfsdk=33
  396. set keyrev=04
  397. set fwver=0003004000000000
  398. set ctrlflagswitch=TRUE
  399. set capflagswitch=FALSE
  400. echo [*] Output set to 3.XX ALT.
  401. echo.
  402. ping localhost -n 2 >nul
  403. goto default_mode
  404. )
  405. if %output%==3xxalt (
  406. set output=4xxstd
  407. set outputmsg=[4.XX STD]
  408. set elfsdk=41
  409. set keyrev=1C
  410. set fwver=0004002000000000
  411. set ctrlflagswitch=FALSE
  412. set capflagswitch=FALSE
  413. echo.
  414. echo [*] Output set to 4.XX STD.
  415. ping localhost -n 2 >nul
  416. goto default_mode
  417. )
  418.  
  419. :change_mode
  420. if %opt%==/cex goto set_cex
  421. if %opt%==/CEX goto set_cex
  422. if %opt%==/dex goto set_dex
  423. if %opt%==/DEX goto set_dex
  424. :set_cex
  425. set mode=CEX
  426. echo.
  427. echo CEX mode enabled.
  428. ping localhost -n 2 >nul
  429. goto cex_menu
  430. :set_dex
  431. set mode=DEX
  432. echo.
  433. echo DEX mode enabled.
  434. ping localhost -n 2 >nul
  435. goto dex_menu
  436.  
  437. :error
  438. echo.
  439. if %opt%==/cex goto fw_error
  440. if %opt%==/CEX goto fw_error
  441. if %opt%==/dex goto fw_error
  442. if %opt%==/DEX echo fw_error
  443. if %mode%==CEX echo [^^!] "%opt%" is not a valid option.
  444. if %mode%==DEX echo [^^!] "%opt%" is not a valid option.
  445. ping localhost -n 3 >nul
  446. goto default_mode
  447. :fw_error
  448. if %opt%==/cex echo [^^!] CEX mode is already enabled.
  449. if %opt%==/CEX echo [^^!] CEX mode is already enabled.
  450. if %opt%==/dex echo [^^!] DEX mode is already enabled.
  451. if %opt%==/DEX echo [^^!] DEX mode is already enabled.
  452. ping localhost -n 3 >nul
  453. goto default_mode
  454.  
  455. :about
  456. echo.
  457. echo R3D Apple is a resigning tool developed to quickly and simply encrypt/decrypt EBOOTs.
  458. echo.
  459. echo Waiting on %user%...
  460. pause >nul
  461. goto default_mode
  462.  
  463. :credits
  464. cls
  465. echo R3D Apple Resigner developed by Jet
  466. echo Released Sept. 22, 2016
  467. echo NGU: TrippinOnACID
  468. echo RG: Jet
  469. echo.
  470. echo Shout out to Trojan and Krank
  471. echo.
  472. echo Waiting on %user%...
  473. pause >nul
  474. goto default_mode
  475.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement