@echo off
color 0A
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo                oooooooooooo      88  .oooooo..o      88  .oooooo..o      88  .oooooo..o      88 oooooooooooo
echo                `888'     `8     .8' d8P'    `Y8     .8' d8P'    `Y8     .8' d8P'    `Y8     .8' `888'     `8
echo                 888            .8'  Y88bo.         .8'  Y88bo.         .8'  Y88bo.         .8'   888        
echo                 888oooo8      .8'    `"Y8888o.    .8'    `"Y8888o.    .8'    `"Y8888o.    .8'    888oooo8   
echo                 888    "     .8'         `"Y88b  .8'         `"Y88b  .8'         `"Y88b  .8'     888    "   
echo                 888       o .8'     oo     .d8P .8'     oo     .d8P .8'     oo     .d8P .8'      888       o
echo                o888ooooood8 88      8""88888P'  88      8""88888P'  88      8""88888P'  88      o888ooooood8
ping 127.0.0.1 -n 2 > nul
echo.
echo                                                  ( PRONOUNCED "EASY")
echo.
ping 127.0.0.1 -n 2 > nul
echo                                                       Version 4.3

:menu

ping 127.0.0.1 -n 2 > nul

if exist kli.txt del kli.txt
if exist kl.txt del kl.txt
if exist fw.txt del fw.txt
if exist lic.txt del lic.txt
if exist cont.txt del cont.txt
if exist lice.txt del lice.txt
if exist typ.txt del typ.txt
if exist klic.bin del klic.bin
if exist ver.txt del ver.txt
if exist cid.txt del cid.txt
if exist titled.txt del titled.txt
if exist tid.txt del tid.txt
if exist results.txt del results.txt
if exist selfinfo.txt del selfinfo.txt
if exist update.txt del update.txt
if exist devk.txt del devk.txt
if exist k2.txt del k2.txt
if exist devk2.txt del devk2.txt
if exist title.txt del title.txt
if exist package.conf del package.conf
if exist exec.txt del exec.txt
if exist prx.txt del prx.txt
if exist NKF.txt del NKF.txt
if exist klic2.txt del klic2.txt
if exist klic3.txt del klic3.txt
if exist 355.txt del 355.txt
if exist 421.txt del 421.txt
if exist np355.txt del np355.txt
if exist np421.txt del np421.txt
if exist content.txt del content.txt
if exist edatinfo.txt del edatinfo.txt
if exist edatinfo2.txt del edatinfo2.txt
if exist deckey.txt del deckey.txt
if exist devkey.txt del devkey.txt
if exist edtflg.txt del edtflg.txt
cls
echo ===============================================================================
echo =++++++++++++++++++++++++++++++++++E+S+S+S+E+v4+++++++++++++++++++++++++++++++=
echo ===============================================================================
echo ============    ----------------------------------------------     ============
echo ===========     ODE and CFW EBOOT/SELF/SPRX/SDAT/EDAT Resigner      ===========
echo ==========      ----------------------------------------------       ==========
echo =========                                                             =========
echo ========      A. Resign EBOOT           G. ADD a klicense to list      ========
echo =======                                                                 =======
echo ======        B. Resign SELF Files      H. Edit PARAM.SFO                ======
echo =====                                                                     =====
echo =====         C. Resign SPRX Files      I. Make c00 license Edat          =====
echo =====                                                                     =====
echo =====         D. Resign SDAT Files      J. Convert RAPS to RIFS           =====
echo ======                                                                   ======
echo =======       E. Resign EDAT Files      K. About E/S/S/S/E Resigner     =======
echo ========                                                               ========
echo =========     F. Bruteforce EDAT        L. EXIT                       =========
echo ==========                                                           ==========
echo ===============================================================================
echo **     Resign your EBOOT/SELF/SPRX/SDAT/EDAT files for use in ODE or CFW     **
echo *******************************************************************************
echo ===============================================================================
echo.
CHOICE /C abcdefghijkl /N /M "Select a Letter:"

IF %errorlevel%==1 goto EBOOT
IF %errorlevel%==2 goto SELF
IF %errorlevel%==3 goto SPRX
IF %errorlevel%==4 goto SDAT
IF %errorlevel%==5 goto EDAT
IF %errorlevel%==6 goto BFEDAT
IF %errorlevel%==7 goto KLICE
IF %errorlevel%==8 goto SFO
IF %errorlevel%==9 goto c00
IF %errorlevel%==10 goto rifs
IF %errorlevel%==11 goto ABOUT
IF %errorlevel%==12 goto exit
pause
cls
goto menu

:EBOOT
cls
set DIR_RAP=RAPS

echo Make sure EBOOT.BIN is in this folder...
pause

if exist EBOOT.ELF echo Unknown "EBOOT.ELF" found in folder!
if exist EBOOT.ELF pause
if exist EBOOT.ELF (goto menu)
if not exist EBOOT.BIN echo No "EBOOT.BIN" found in folder!
if not exist EBOOT.BIN pause
if not exist EBOOT.BIN (goto menu)

scetool.exe -i EBOOT.BIN >selfinfo.txt
for /f "skip=3 tokens=1,*" %%a in (selfinfo.txt) do if "%%a"=="ContentID" set contentid=%%b
echo %contentid% >cid.txt
for /f "tokens=2 delims=-,_" %%c in (cid.txt) do set titleid=%%c
for /f "skip=3 tokens=1,*" %%d in (selfinfo.txt) do if "%%d"=="Licence" set Licence=%%e
for /f "skip=3 tokens=1,*" %%f in (selfinfo.txt) do if "%%f"=="SELF-Type" set type=%%g
for /f "skip=3 tokens=1,*" %%h in (selfinfo.txt) do if "%%h"=="App" set app=%%i
for /f "skip=3 tokens=1,*" %%j in (selfinfo.txt) do if "%%j"=="FW" set FW=%%k
for /f "skip=3 tokens=1,*" %%p in (selfinfo.txt) do if "%%p"=="Key" set Key=%%q
echo %FW% >fw.txt
for /f "tokens=3" %%l in (fw.txt) do set fwv=%%l
find /I "[EXEC]" selfinfo.txt >exec.txt
find /I "[PRX]" selfinfo.txt >prx.txt
for /f "skip=2 tokens=2" %%m in (exec.txt) do set ex=%%m
for /f "skip=2 tokens=2" %%n in (prx.txt) do set xpr=%%n
if "%ex%"=="[EXEC]" set ELF_TYPE=[EXEC]
if "%xpr%"=="[PRX]" set ELF_TYPE=[PRX]
if "%app%"=="Type     0x00000000" set apptype=SPRX
if "%app%"=="Type     0x00000001" set apptype=EXEC
if "%app%"=="Type     0x00000020" set apptype=USPRX
if "%app%"=="Type     0x00000021" set apptype=UEXEC


if "%Licence%"=="Type 0x00000001" echo ****************************************
if "%Licence%"=="Type 0x00000001" cls
if "%Licence%"=="Type 0x00000001" echo ****************************************
if "%Licence%"=="Type 0x00000001" echo ***************[WARNING]****************
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo *  This is a NETWORK TYPE NPDRM EBOOT  *
if "%Licence%"=="Type 0x00000001" echo * Game Needs Online Connection to Run! *
if "%Licence%"=="Type 0x00000001" echo *   Place rap file in "RAPS" folder    *
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo *************[Content-ID]***************
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo * %contentid% *
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo ***************[Title-ID]***************
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo *              [%titleid%]             *
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo ***************[Firmware]***************
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo *          FW Version %fwv%          *
if "%Licence%"=="Type 0x00000001" echo *                                      *
if "%Licence%"=="Type 0x00000001" echo ****************************************
if "%Licence%"=="Type 0x00000001" pause
if "%Licence%"=="Type 0x00000001" (goto cde)
if not "%Licence%"=="Type 0x00000001" (goto gbg)

:gbg
if "%Licence%"=="Type 0x00000002" echo ****************************************
if "%Licence%"=="Type 0x00000002" cls
if "%Licence%"=="Type 0x00000002" echo ****************************************
if "%Licence%"=="Type 0x00000002" echo ***************[WARNING]****************
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo * This is a LOCAL TYPE NPDRM EBOOT.BIN *
if "%Licence%"=="Type 0x00000002" echo *   Place rap file in "RAPS" folder    *
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo *************[Content-ID]***************
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo * %contentid% *
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo ***************[Title-ID]***************
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo *              [%titleid%]             *
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo ***************[Firmware]***************
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo *          FW Version %fwv%          *
if "%Licence%"=="Type 0x00000002" echo *                                      *
if "%Licence%"=="Type 0x00000002" echo ****************************************
if "%Licence%"=="Type 0x00000002" pause
if "%Licence%"=="Type 0x00000002" (goto cde)
if not "%Licence%"=="Type 0x00000002" (goto yhr)

:cde
if not exist "%DIR_RAP%"\"%contentid%.rap" echo =======================
if not exist "%DIR_RAP%"\"%contentid%.rap" cls
if not exist "%DIR_RAP%"\"%contentid%.rap" echo =======================
if not exist "%DIR_RAP%"\"%contentid%.rap" echo *******[WARNING]*******
if not exist "%DIR_RAP%"\"%contentid%.rap" echo =======================
if not exist "%DIR_RAP%"\"%contentid%.rap" echo. 
if not exist "%DIR_RAP%"\"%contentid%.rap" echo   No or Wrong rap in
if not exist "%DIR_RAP%"\"%contentid%.rap" echo   RAPS folder  Can't 
if not exist "%DIR_RAP%"\"%contentid%.rap" echo   Decrypt this Eboot 
if not exist "%DIR_RAP%"\"%contentid%.rap" echo.  
if not exist "%DIR_RAP%"\"%contentid%.rap" echo =======================
if not exist "%DIR_RAP%"\"%contentid%.rap" pause
if not exist "%DIR_RAP%"\"%contentid%.rap" cls
if not exist "%DIR_RAP%"\"%contentid%.rap" goto menu


:yhr
if "%Licence%"=="Type 0x00000003" echo ****************************************
if "%Licence%"=="Type 0x00000003" cls
if "%Licence%"=="Type 0x00000003" echo ****************************************
if "%Licence%"=="Type 0x00000003" echo **************[WARNING]*****************
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo * This is a FREE TYPE NPDRM EBOOT.BIN  *
if "%Licence%"=="Type 0x00000003" echo * other files in pkg may need klicense *
if "%Licence%"=="Type 0x00000003" echo * (i.e SELF, SPRX)                     *
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo *************[Content-ID]***************
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo * %contentid% *
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo ***************[Title-ID]***************
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo *              [%titleid%]             *
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo ***************[Firmware]***************
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo *          FW Version %fwv%          *
if "%Licence%"=="Type 0x00000003" echo *                                      *
if "%Licence%"=="Type 0x00000003" echo ****************************************
if "%Licence%"=="Type 0x00000003" pause
if not "%Key%"=="Revision    [DEBUG]" (goto scetool1)

:dwd
if "%Key%"=="Revision    [DEBUG]" cls
if "%Key%"=="Revision    [DEBUG]" echo ****************************************
if "%Key%"=="Revision    [DEBUG]" echo ***************[WARNING]****************
if "%Key%"=="Revision    [DEBUG]" echo *                                      *
if "%Key%"=="Revision    [DEBUG]" echo *     This is a DEBUG EBOOT.BIN        *
if "%Key%"=="Revision    [DEBUG]" echo *                                      *
if "%Key%"=="Revision    [DEBUG]" echo *    Do you want to Decrypt FSELF      *
if "%Key%"=="Revision    [DEBUG]" echo *                                      *
if "%Key%"=="Revision    [DEBUG]" echo *              1. YES                  *    
if "%Key%"=="Revision    [DEBUG]" echo *              2. NO                   *
if "%Key%"=="Revision    [DEBUG]" echo *                                      *
if "%Key%"=="Revision    [DEBUG]" echo ****************************************
if "%Key%"=="Revision    [DEBUG]" set /p DG= Your Choice (1-2):
if "%Key%"=="Revision    [DEBUG]" if %DG%==1 (goto debug)
if "%Key%"=="Revision    [DEBUG]" if %DG%==2 (goto menu)
if "%Key%"=="Revision    [DEBUG]" echo You can only choose 1-2
if "%Key%"=="Revision    [DEBUG]" pause
if "%Key%"=="Revision    [DEBUG]" cls
if "%Key%"=="Revision    [DEBUG]" goto dwd

:scetool1
scetool -v -d "EBOOT.BIN" "EBOOT.ELF"
if not exist "EBOOT.ELF" scetool.exe -l 74376384BA498BFF3DBB949F0B6A929D -v -d "EBOOT.BIN" "EBOOT.ELF"
if not exist "EBOOT.elf" scetool.exe -l B8498B3492E822F7D2390862568B03C7 -v -d "EBOOT.BIN" "EBOOT.ELF"
if not exist "EBOOT.ELF" scetool.exe -v -r -d "EBOOT.BIN" "EBOOT.ELF"
if not exist "EBOOT.ELF" pause
if not exist "EBOOT.ELF" cls
if not exist "EBOOT.ELF" echo *****************************
if not exist "EBOOT.ELF" echo * Cannot Decrypt EBOOT.BIN  *
if not exist "EBOOT.ELF" echo *****************************
if not exist "EBOOT.ELF" pause
if not exist "EBOOT.ELF" cls
if not exist "EBOOT.ELF" call "ESSSE_RESIGNER.bat"
if exist EBOOT.ELF FixELF.exe "EBOOT.ELF"
if exist EBOOT.ELF rename EBOOT.BIN EBOOT.BIN.ORIG

if "%type%"=="[Application]" (goto disc)
if "%Licence%"=="Type 0x00000001" (goto network)
if "%Licence%"=="Type 0x00000002" (goto local)
if "%Licence%"=="Type 0x00000003" (goto free)
if "%Licence%"=="Type   [FREE]" (goto free)

:disc
cls
echo =======================
echo   FW Version %fwv% 
echo =======================
echo ***[DISC TYPE EBOOT]***
echo =======================
echo.
echo   1. Resign to 3.55 (ODE)
echo.
echo   2. Resign to 3.55
echo.
echo   3. Resign to 4.21
echo.
echo   4. Resign to DEX (NON-DRM)
echo.
echo   5. Resign to DEX (NPDRM)
echo =======================

set /p sic= Your Choice (1-5):
if %sic%==1 (goto 355)
if %sic%==2 (goto 355cfw)
if %sic%==3 (goto 421)
if %sic%==4 (goto DEX)
if %sic%==5 (goto npDEX)
echo You can only choose 1-5
pause
cls
goto disc

:network
cls
echo               ==============================
echo               *****[NETWORK TYPE NPDRM]*****
echo =============================================================
echo ------------------------------ ------------------------------
echo   Resign to FREE TYPE NPDRM         Resign to DEX NPDRM 
echo ------------------------------ ------------------------------
echo.
echo     1. Resign to FREE TYPE        6. Resign to DEX NPDRM
echo            NPDRM 3.55
echo. 
echo     2. Resign to FREE TYPE
echo            NPDRM 4.21
echo.
echo =============================== =============================
echo    Resign to DISC TYPE APP         Resign to DEX Disc Type 
echo ------------------------------- -----------------------------
echo.  
echo     3. Resign to 3.55 (ODE)       7. Resign to DEX NON-DRM
echo.
echo     4. Resign to 3.55
echo.
echo     5. Resign to 4.21
echo.
echo =============================================================

set /p nick= Your Choice (1-7):
if %nick%==1 (goto np355)
if %nick%==2 (goto np421)
if %nick%==3 (goto 355)
if %nick%==4 (goto 355cfw)
if %nick%==5 (goto 421)
if %nick%==6 (goto npDEX)
if %nick%==7 (goto DEX)
echo You can only choose 1-7
pause
cls
goto network

:local
cls
echo               ==============================
echo               ******[LOCAL TYPE NPDRM]******
echo =============================================================
echo ------------------------------ ------------------------------
echo   Resign to FREE TYPE NPDRM         Resign to DEX NPDRM 
echo ------------------------------ ------------------------------
echo.
echo     1. Resign to FREE TYPE        6. Resign to DEX NPDRM
echo            NPDRM 3.55
echo. 
echo     2. Resign to FREE TYPE
echo            NPDRM 4.21
echo.
echo =============================== =============================
echo    Resign to DISC TYPE APP         Resign to DEX Disc Type 
echo ------------------------------- -----------------------------
echo.  
echo     3. Resign to 3.55 (ODE)       7. Resign to DEX NON-DRM
echo.
echo     4. Resign to 3.55
echo.
echo     5. Resign to 4.21
echo.
echo =============================================================

set /p sick= Your Choice (1-7):
if %sick%==1 (goto np355)
if %sick%==2 (goto np421)
if %sick%==3 (goto 355)
if %sick%==4 (goto 355cfw)
if %sick%==5 (goto 421)
if %sick%==6 (goto npDEX)
if %sick%==7 (goto DEX)
echo You can only choose 1-7
pause
cls
goto local

:free
cls
echo                ==============================
echo                ******[FREE TYPE NPDRM]*******
echo ===========================================================
echo ------------------------------ ----------------------------
echo     Resign FREE TYPE NPDRM         Resign to DEX NPDRM 
echo ------------------------------ ----------------------------
echo.
echo     1. Resign to FREE TYPE       6. Resign to DEX NPDRM
echo            NPDRM 3.55
echo. 
echo     2. Resign to FREE TYPE
echo            NPDRM 4.21
echo.
echo =============================== ===========================
echo    Resign to DISC TYPE APP        Resign to DEX DISC TYPE 
echo ------------------------------- ---------------------------
echo.
echo     3. Resign to 3.55 (ODE)      7. Resign to DEX NON-DRM
echo.
echo     4. Resign to 3.55
echo.
echo     5. Resign to 4.21
echo.
echo ===========================================================

set /p sik= Your Choice (1-7):
if %sik%==1 (goto np355)
if %sik%==2 (goto np421)
if %sik%==3 (goto 355)
if %sik%==4 (goto 355cfw)
if %sik%==5 (goto 421)
if %sik%==6 (goto npDEX)
if %sik%==7 (goto DEX)
echo You can only choose 1-7
pause
cls
goto free

:dedebug
cls
echo ==========================
echo    Resign DEBUG EBOOT!
echo ==========================
echo.
echo   1. Resign to DEX NPDRM
echo.
echo   2. Resign to DEX NON-DRM
echo.
echo ===========================
set /p dexr= Your Choice (1-2):
if %dexr%==1 (goto npDEX)
if %dexr%==2 (goto DEX)
echo You can only choose 1-2
pause
cls
goto dedebug

if not exist EBOOT.ELF cls
if not exist EBOOT.ELF echo ====================================
if not exist EBOOT.ELF echo *************[WARNING]**************
if not exist EBOOT.ELF echo ====================================
if not exist EBOOT.ELF echo.
if not exist EBOOT.ELF echo Could not Decrypt EBOOT.BIN  No Rap 
if not exist EBOOT.ELF echo.
if not exist EBOOT.ELF echo ====================================
if not exist EBOOT.ELF pause
if not exist EBOOT.ELF cls
if not exist EBOOT.ELF goto menu

:debug
cls
if not exist EBOOT.ELF unfself EBOOT.BIN EBOOT.ELF
if not exist EBOOT.ELF unself EBOOT.BIN EBOOT.ELF
if not exist EBOOT.ELF pause
if not exist EBOOT.ELF echo ================================
if not exist EBOOT.ELF echo  Can't Decrypt this DEBUG EBOOT
if not exist EBOOT.ELF echo ================================
if not exist EBOOT.ELF echo pause
if not exist EBOOT.ELF echo cls
if not exist EBOOT.ELF echo goto menu
:debugd
if exist EBOOT.ELF echo ===================================
if exist EBOOT.ELF echo     DEBUG EBOOT.BIN Decrypted!
if exist EBOOT.ELF echo ===================================
if exist EBOOT.ELF echo.
if exist EBOOT.ELF echo     Do you want to Resign it
if exist EBOOT.ELF echo.
if exist EBOOT.ELF echo              1. YES
if exist EBOOT.ELF echo              2. NO
if exist EBOOT.ELF echo.
if exist EBOOT.ELF echo ------------------------------------
if exist EBOOT.ELF set /p drs= Choose 1 or 2 :
if exist EBOOT.ELF if %drs%==1 (goto dedebug)
if exist EBOOT.ELF if %drs%==2 (goto menu)
if exist EBOOT.ELF echo You can only choose 1-2
if exist EBOOT.ELF pause
if exist EBOOT.ELF cls
if exist EBOOT.ELF goto debugd

:355
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=TRUE
if %comp%==2 set ce=FALSE
cls
if "%ELF_TYPE%"=="[EXEC]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --self-add-shdrs=TRUE --compress-data=%ce% --key-revision=0A --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-type=APP --self-fw-version=0003005500000000 --encrypt EBOOT.ELF EBOOT.BIN
if "%ELF_TYPE%"=="[PRX]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --self-add-shdrs=TRUE --compress-data=FALSE --key-revision=0A --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-type=APP --self-fw-version=0003005500000000 --encrypt EBOOT.ELF EBOOT.BIN
goto finish

:355cfw
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=TRUE
if %comp%==2 set ce=FALSE
cls
if "%ELF_TYPE%"=="[EXEC]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --compress-data=%ce% --self-add-shdrs=TRUE --key-revision=0A --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-app-version=0001000000000000 --self-type=APP --self-fw-version=0003005500000000 --encrypt EBOOT.ELF EBOOT.BIN
if "%ELF_TYPE%"=="[PRX]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --self-add-shdrs=TRUE --compress-data=FALSE --key-revision=0A --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-type=APP --self-fw-version=0003005500000000 --encrypt EBOOT.ELF EBOOT.BIN
goto finish

:DEX
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=-c
if %comp%==2 set ce=-u
cls
make_fself %ce% EBOOT.ELF EBOOT.BIN
goto finish

:421
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=TRUE
if %comp%==2 set ce=FALSE
cls
if "%ELF_TYPE%"=="[EXEC]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --compress-data=%ce% --self-add-shdrs=TRUE --key-revision=1C --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-app-version=0001000000000000 --self-type=APP --self-fw-version=0004002100000000 --encrypt EBOOT.ELF EBOOT.BIN
if "%ELF_TYPE%"=="[PRX]" scetool --verbose --sce-type=SELF --skip-sections=FALSE --self-add-shdrs=TRUE --compress-data=FALSE --key-revision=1C --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100040000 --self-type=APP --self-fw-version=0004002100000000 --encrypt EBOOT.ELF EBOOT.BIN
goto finish

:np355
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=TRUE
if %comp%==2 set ce=FALSE
cls
if "%ELF_TYPE%"=="[EXEC]" scetool --verbose --skip-sections=FALSE --sce-type=SELF --compress-data=%ce% --key-revision=0A --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100020000 --self-type=NPDRM --self-fw-version=0003005500000000 --np-license-type=FREE --np-app-type=%apptype% --np-content-id=%contentid% --np-real-fname=EBOOT.BIN --encrypt EBOOT.ELF EBOOT.BIN
if "%ELF_TYPE%"=="[PRX]" scetool --verbose --skip-sections=FALSE --sce-type=SELF --compress-data=FALSE --key-revision=0A --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100020000 --self-type=NPDRM --self-fw-version=0003005500000000 --np-license-type=FREE --np-app-type=%apptype% --np-content-id=%contentid% --np-real-fname=EBOOT.BIN --encrypt EBOOT.ELF EBOOT.BIN
goto finish

:npDEX
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=-c
if %comp%==2 set ce=-u
cls
make_fself_npdrm %ce% EBOOT.ELF EBOOT.BIN
goto finish

:np421
cls
echo ============================
echo Compress Eboot   1.YES  2.NO
echo ============================
set /p comp= Choose 1 or 2 :
if %comp%==1 set ce=TRUE
if %comp%==2 set ce=FALSE
cls
if "%ELF_TYPE%"=="[EXEC]" scetool --verbose --skip-sections=FALSE --sce-type=SELF --compress-data=%ce% --key-revision=1C --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100020000 --self-type=NPDRM --self-fw-version=0004002100000000 --np-license-type=FREE --np-app-type=%apptype% --np-content-id=%contentid% --np-real-fname=EBOOT.BIN --encrypt EBOOT.ELF EBOOT.BIN
if "%ELF_TYPE%"=="[PRX]" scetool --verbose --skip-sections=FALSE --sce-type=SELF --compress-data=FALSE --key-revision=1C --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-ctrl-flags=0000000000000000000000000000000000000000000000000000000000000000 --self-cap-flags=00000000000000000000000000000000000000000000003B0000000100020000 --self-type=NPDRM --self-fw-version=0004002100000000 --np-license-type=FREE --np-app-type=%apptype% --np-content-id=%contentid% --np-real-fname=EBOOT.BIN --encrypt EBOOT.ELF EBOOT.BIN
goto finish

:finish

if exist EBOOT.ELF del EBOOT.ELF
if exist EBOOT.BIN echo.
if exist EBOOT.BIN echo =====================
if exist EBOOT.BIN echo Auto-resign finished
if exist EBOOT.BIN echo =====================
if not exist EBOOT.BIN echo Can't Resign this Eboot
pause
cls
goto menu

:KLICE
cls
echo =======================================================================
echo *******************ONLY ENTER VALID KLICENSES***************************
echo *******DELETE NON-WORKING ONES FROM BOTTOM OF KLICENSE.TXT*************
echo =======================================================================
echo.
echo                Title-ID Example - [NPUB000000]
echo.
echo              Content-ID Example - JP9000-NPJA60003_00-0000000000000000
echo.
set /p ID= ENTER "TITLE-ID" or "CONTENT-ID" :
echo.
echo                Klicense Example - 00000000000000000000000000000000
echo.
set /p eklic= PLEASE  ENTER  "klicense"  HERE  :
echo=========================================================================
echo.
echo %eklic% %ID% >>klicense.txt
echo.
echo NEW "klicense" added to List
pause
cls
goto menu

:SELF
cls
echo.
echo Make sure SELF files are in "SELF_FILES" folder
echo.
pause
cls
SET DIR_SRC=SELF_Files
SET DIR_DEST=Resigned_SELFS
SET DIR_ORIG=ORIGINAL_FILES
SET DIR_RAP=RAPS

del /F /Q %DIR_DEST%\*.*
if exist 355.txt del 355.txt
if exist 421.txt del 421.txt
if exist np355.txt del np355.txt
if exist np421.txt del np421.txt
xcopy %DIR_SRC%\*.self %DIR_ORIG%\ /Y
for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do call make1.bat "%%~nf"

if exist %DIR_DEST%\*.SELF cls
if exist %DIR_DEST%\*.SELF echo **********************
if exist %DIR_DEST%\*.SELF echo ======================
if exist %DIR_DEST%\*.SELF echo *.SELF Files Resigned.
if exist %DIR_DEST%\*.SELF echo ======================
if exist %DIR_DEST%\*.SELF echo **********************

pause
if exist kli.txt del kli.txt
if exist tid.txt del tid.txt
if exist results.txt del results.txt
cls
ENDLOCAL
goto menu


:SPRX

echo.
echo Make sure SPRX files are in "SPRX_FILES" folder
echo.
pause
cls
SET DIR_SRC=SPRX_Files
SET DIR_DEST=Resigned_SPRX
SET DIR_ORIG=ORIGINAL_FILES
SET DIR_RAP=RAPS

del /F /Q %DIR_DEST%\*.*
if exist 355.txt del 355.txt
if exist 421.txt del 421.txt
if exist np355.txt del np355.txt
if exist np421.txt del np421.txt
xcopy %DIR_SRC%\*.sprx %DIR_ORIG%\ /Y
for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do call make2.bat "%%~nf"

if exist %DIR_DEST%\*.SPRX cls
if exist %DIR_DEST%\*.SPRX echo **********************
if exist %DIR_DEST%\*.SPRX echo ======================
if exist %DIR_DEST%\*.SPRX echo *.SPRX Files Resigned.
if exist %DIR_DEST%\*.SPRX echo ======================
if exist %DIR_DEST%\*.SPRX echo **********************

pause
if exist kl.txt del kl.txt
if exist tid.txt del tid.txt
if exist results.txt del results.txt
cls
ENDLOCAL
goto menu

:SDAT

echo.
echo Make sure SDAT files are in "SDAT_FILES" folder
echo.
pause
cls
SET DIR_SRC=SDAT_Files
SET DIR_DEST=Resigned_SDAT
SET DIR_ORIG=ORIGINAL_FILES

del /F /Q %DIR_DEST%\*.*

xcopy %DIR_SRC%\*.SDAT %DIR_ORIG%\ /Y
for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do call make3.bat "%%~nf"

if exist %DIR_DEST%\*.SDAT echo ======================
if exist %DIR_DEST%\*.SDAT echo *.SDAT Files Resigned.
if exist %DIR_DEST%\*.SDAT echo ======================
if not exist %DIR_DEST%\*.SDAT echo ========================
if not exist %DIR_DEST%\*.SDAT echo Could not Decrypt files
if not exist %DIR_DEST%\*.SDAT echo ========================
pause
cls
ENDLOCAL
goto menu

:EDAT

echo.
echo Make sure EDAT files are in "EDAT_FILES" folder
echo.
pause
cls
SET DIR_SRC=EDAT_Files
SET DIR_DEST=Resigned_EDAT
SET DIR_RAP=RAPS
SET DIR_ORIG=ORIGINAL_FILES

del /F /Q %DIR_DEST%\*.*

xcopy %DIR_SRC%\*.EDAT %DIR_ORIG%\ /Y
for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do call make4.bat "%%~nf"

if exist %DIR_DEST%\*.EDAT cls
if exist %DIR_DEST%\*.EDAT echo ======================
if exist %DIR_DEST%\*.EDAT echo *.EDAT Files Resigned.
if exist %DIR_DEST%\*.EDAT echo ======================
pause
cls
ENDLOCAL
goto menu



:SFO
echo.
echo Make sure PARAM.SFO is in this folder...
echo.
pause
cls

if exist PARAM.SFO cls
if exist PARAM.SFO echo =======================
if exist PARAM.SFO echo    PARAM.SFO will be 
if exist PARAM.SFO echo  displayed for editing
if exist PARAM.SFO echo -----------------------
if exist PARAM.SFO echo Be sure to Set Catagory
if exist PARAM.SFO echo to: 
if exist PARAM.SFO echo     DG Disc Game
if exist PARAM.SFO echo     HG Harddrive Game
if exist PARAM.SFO echo     GD Game Data
if exist PARAM.SFO echo -----------------------
if exist PARAM.SFO echo Also Set PS3_System to
if exist PARAM.SFO echo FW below yours: 
if exist PARAM.SFO echo                 4.20
if exist PARAM.SFO echo                 3.55
if exist PARAM.SFO echo                 3.40
if exist PARAM.SFO echo =======================
if exist PARAM.SFO echo  Be sure to save file
if exist PARAM.SFO echo =======================
if exist PARAM.SFO pause

PARAM_SFO_Editor.exe PARAM.SFO

if not exist PARAM.SFO cls
if not exist PARAM.SFO echo =========================
if not exist PARAM.SFO echo ********[WARNING]********
if not exist PARAM.SFO echo =========================
if not exist PARAM.SFO echo.
if not exist PARAM.SFO echo Could not find PARAM.SFO
if not exist PARAM.SFO echo.
if not exist PARAM.SFO echo =========================
pause
cls
goto menu


:rifs
SETLOCAL
cls
echo.
echo =========================================
echo  Converts Raps to Rifs and puts into Pkg
echo =========================================
echo.
echo   1. Replace act,dat and idps files in
echo      data folder with yours. Will not work 
echo      with temp ones currently in folder.
echo.
echo   2. Put Raps in RAPS folder.
echo.
echo   3. Will convert Raps to Rifs and put them
echo      in a Pkg file in PKG folder. Pkg will 
echo      install Rifs in your /exdata folder.
echo.
echo ===========================================
echo  ^*Rifs will only work with YOUR act.dat 
echo    and idps in /data folder!
echo ===========================================
pause
if exist rif.txt del rif.txt
if exist rifs RD /S /Q rifs
if not exist RAPS/*.rap echo.
if not exist RAPS/*.rap echo =======================
if not exist RAPS/*.rap echo No Raps in RAPS folder.
if not exist RAPS/*.rap echo =======================
if not exist RAPS/*.rap echo.
if not exist RAPS/*.rap pause
if not exist RAPS/*.rap goto menu
if not exist data/act.dat echo.
if not exist data/act.dat echo ==========================
if not exist data/act.dat echo No act.dat in data folder.
if not exist data/act.dat echo ==========================
if not exist data/act.dat echo.
if not exist data/act.dat pause
if not exist data/act.dat goto menu
if not exist data/idps echo.
if not exist data/idps echo =======================
if not exist data/idps echo No IDPS in data folder.
if not exist data/idps echo =======================
if not exist data/idps echo.
if not exist data/idps pause
if not exist data/idps goto menu

R2R.exe -s RAPS

SET DIR_SRC=rifs

for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do goto nex

:nex
for /F "tokens=*" %%* in ('dir /b rifs\*.rif') do set rif=%%*
echo %rif%>>rif.txt
for /f "tokens=1 delims=." %%G IN (rif.txt) DO set nrif=%%G

if not exist pkg MD PKG
SET DIR_FIN=PKG

make_package_license -c %nrif% rifs %DIR_FIN%\%nrif%.pkg  
if exist rif.txt del rif.txt
if exist rifs RD /S /Q rifs
color 0a
cls
echo.
echo ============================
echo ****************************
echo ============================
echo    Pkg is in PKG folder!
echo ============================
pause
cls
ENDLOCAL
goto menu

:c00
cls
echo ==========================
echo **************************
echo ==========================
echo Would you like c00 Licence
echo Edat in pkg Installer or
echo just Edat file
echo --------------------------
echo   1. c00 Licence Edat Pkg
echo      Installer
echo.
echo   2. Just Edat File
echo ==========================
set /p choic= Select (1-2)
if %choic%==1 (goto pkge)
if %choic%==2 (goto edatf)
echo Only choose 1 or 2!
pause
cls
goto c00

:pkge
cls
echo ==========================================================================
echo =********** Install c00 Edat Licence Pkg on CFW PS3 only ****************=
echo ==========================================================================
echo *                                                                        *
echo *      Example Content-ID :JP9000-NPJA60003_00-0000000000000000          *
echo *                                                                        *
set /p contid= * PASTE "CONTENT-ID" HERE :
echo *                                                                        *
echo ==========================================================================

make_c00_edat "%contid%.edat" %contid% 3
move *.edat Demo_c00_Edat\
make_package_license -c %contid% Demo_c00_Edat Demo_c00_Edat\%contid%.pkg
del Demo_c00_Edat\"%contid%.edat"
echo.
echo ========================================================
echo Edat Licence Installer Pkg is in "Demo_c00_Edat" folder
echo ========================================================
pause
cls
goto menu


:edatf
cls
echo ==========================================================================
echo =*************** Put c00 Edat Licence in /exdata folder *****************=
echo ==========================================================================
echo *                                                                        *
echo *      Example Content-ID :JP9000-NPJA60003_00-0000000000000000          *
echo *                                                                        *
set /p contid= * PASTE "CONTENT-ID" HERE :
echo *                                                                        *
echo ==========================================================================
make_c00_edat "%contid%.edat" %contid% 3
move *.edat Demo_c00_Edat\
echo.
echo =======================================
echo Edat Licence in "Demo_c00_Edat" folder
echo =======================================
pause
cls
goto menu

:BFEDAT


echo.
echo Make sure Games EBOOT.BIN and *.EDAT file are in "EDAT_Bruteforce" folder!
echo.
pause
cls

set DIR_SRC=EDAT_Bruteforce
set DIR_DEST=EDAT_Files
set DIR_ORIG=ORIGINAL_FILES
set DIR_RAP=RAPS

del /F /Q %DIR_DEST%\*.*
xcopy %DIR_SRC%\*.BIN %DIR_ORIG%\ /Y
xcopy %DIR_SRC%\*.EDAT %DIR_ORIG%\ /Y
for /f "delims=|" %%f in ('dir /b %DIR_SRC%') do call make4a.bat "%%~nf"

cls
ENDLOCAL
goto menu





:ABOUT
cls
echo ===============================================================================
echo =/////////////////////////////////////////////////////////////////////////////=
echo ===============================================================================
echo =\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\E/S/S/S/E/v4//////////////////////////////////=
echo ===============================================================================
echo =====                                                                     =====
echo =====            THANKS to all for your help making a easier              =====
echo =====           tool to resign files to work with ODE and CFW             =====
echo =====                                                                     =====
echo ===============================================================================
echo =====                                                                     =====
echo =====     Joonie86 - For finding this program and all his help            =====
echo =====   Aldostools - For FixELF, Klics and other tools he made available  =====
echo =====    nickodimm - For adding batch conversion to the pot               =====
echo =====    bigjokker - Created a GUI,SDAT/EDAT Resigning, NPDRM Decrypting  =====
echo =====        Hykem - For his great SDAT/EDAT tool make_npdata.exe         =====
echo ===== Slimshady451 - For make_c00_edat tool                               =====
echo =====        Pink1 - For R2R.exe                                          =====
echo ===CaptainCPS-X, Aldostools, Rudi Rastelli - For make_package_license.exe =====
echo =====                                                                     =====
echo ===============================================================================
echo /////// Resigning RETAIL PSN GAME and UPDATE files need rap to Decrypt  \\\\\\\
echo ===============================================================================
echo \\\\\\\\\\ Resigning DISC UPDATE and DEMO NPDRM files need klicense  //////////
echo ===============================================================================
echo =+++++++++++++++++++ Resigns all SDK versions to 3.40 ++++++++++++++++++++++++=
echo ===============================================================================

pause
cls
goto menu

:exit
exit