PS2 kelftool and ELF headers

Discussion in 'Tools & Utilties' started by Berion, Dec 5, 2019.

  1. 1,309
    713
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,309
    Likes Received:
    713
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    If the "dirty KELFmake" includes anything from the KELF-V2-Algo (a.k.a. official KEYs), it's probably better to share it via a Pastie!

    That's a bit weird... How does that work? Is the kc 0'd? That sounds pretty interesting and I don't know that much about the HDD-related things (or forgot a lot).


    SCEDoormat is fine, due to how it creates the stuff based on indirectly retrieved stuff. Indirect + Indirect, lol!
     
  2. 82
    234
    57
    krHACKen

    krHACKen Developer

    Joined:
    Nov 2, 2014
    Messages:
    82
    Likes Received:
    234
    Trophy Points:
    57
    Sans titre.png
    That's a homemade KELF. Judging by the file date, I believe that's the FHDB POC MBR KELF from Leo, with the encrypted+signed block moved to the end of the content table.

    EDIT: Yup, that the FHDB POC KELF
    Sans titre.png
     
    svotib, TnA and Berion like this.
  3. 1,309
    713
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,309
    Likes Received:
    713
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    The one with OPL embedded? "FIXMBR.ELF" or what it was? ^^

    Yes, that's legal as well.
    Great to have some of this stuff more sorted and collected in one thread (also to those who possibly can not find it elsewhere and don't already have it).

    Edit: So this version had only a minor part encrypted at the end? An encrypted part for compatibility with MG and the beginning just plain/decrypted? :cool:
     
    Last edited: Dec 7, 2019
  4. 52
    74
    67
    akuhak

    akuhak Member

    Joined:
    Jul 4, 2017
    Messages:
    52
    Likes Received:
    74
    Trophy Points:
    67
    Dirty KelfMaker was based on an old KELF format. It was not working in PSX DVRs and SCPH-50008. I replaced it in HDL Dump project with more modern version from @krHACKen many years ago. Details can be found here:
    https://github.com/AKuHAK/hdl-dump/commit/590aa16e675e0e2743947c4cf935b7e883da83c5
    Whole Header and Footer can be found here: https://github.com/AKuHAK/hdl-dump/blob/master/kelf.h
    In fact, it is possible to provide just simple empty kelf container and with any HEX editor just paste your regular elf into specific offset.

    In fact, some users reported that my implementation works better than SCEDoormat while it has more limitations. Output KELF has static size, so it can handle only ELF with size less than 2 026 464 bytes and the output KELF size will be always 2 027 616 bytes. SCEDoormat can handle any ELF size and output size depends on the input file size. Probably KELF container from HDL-dump project has some more bugs, limitations but its not a question to me.
     
    uyjulian, RandQalan, Berion and 2 others like this.
  5. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland
    Isn't the kelftool is better solution? As I understood, the old methods building some kind of Frankenstein, where kelftool properly encrypt and sign *.elf. If I am right, is the only problems are the keys involved in the process (the legal issues)?
     
    TnA and krHACKen like this.
  6. 82
    234
    57
    krHACKen

    krHACKen Developer

    Joined:
    Nov 2, 2014
    Messages:
    82
    Likes Received:
    234
    Trophy Points:
    57
    It is:cool2:. To use SCEDoormat NoME is pointless now.
     
    TnA and Berion like this.
  7. 769
    1,383
    222
    sp193

    sp193 Developer

    Joined:
    Oct 13, 2014
    Messages:
    769
    Likes Received:
    1,383
    Trophy Points:
    222
    Location:
    Singapore
    Home Page:
    All that tool needs, are more options to allow things like the system type and file type to be set, then you could perhaps do more with it. Right now, it is fixed for the author's needs, from what I can tell.
     
    TnA likes this.
  8. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland

    Attached Files:

    akuhak and jolek like this.
  9. 52
    74
    67
    akuhak

    akuhak Member

    Joined:
    Jul 4, 2017
    Messages:
    52
    Likes Received:
    74
    Trophy Points:
    67
    Can somebody compile the Windows binary? I was trying to compile this stuff in Linux and Windows with no result. In Linux compiled binary crashes with Segmentation Fault error (both: compiled and @Berion 's version). In Windows, I receive various errors while trying to compile with the latest public Visual Studio.
    https://github.com/xfwcfw/kelftool
     
  10. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland
    I also cannot compile it for Windows, downloaded some additional junk, made some modifications point for me by another person on PM and still I was unable to do it. In frustration I uninstalled whole VS. ;p

    Compiling on Linux was just formality... I didn't test it on anything else than 64bit Linux Mint 19.3 with Cinnamon so at least in theory, should works on all Ubuntu kind of distributions from this series. It using openssl, which is not linked static so maybe Your problems whatever non informative to the user are, comes from it? I dunno, I'm not a programmer, just blind shot. ^^
     
  11. 184
    318
    122
    uyjulian

    uyjulian Developer

    Joined:
    May 27, 2017
    Messages:
    184
    Likes Received:
    318
    Trophy Points:
    122
    Gender:
    Male
    Are you getting segmentation fault in function "getKeyStorePath"? You may need to hardcode the path due to C++ scoping rules.
     
  12. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland
    What do You mean? Isn't path is already hardcoded to both systems? Or maybe You have in mind that those must be full paths like i.e. "/home/user/PS2KEYS.dat" or "C:\Users\user\PS2KEYS.dat"?
    Code:
    std::string getKeyStorePath()
    {
    #ifdef __linux__
       return std::string(getenv("HOME")) + "/PS2KEYS.dat";
    #else
       return std::string(getenv("USERPROFILE")) + "\\PS2KEYS.dat";
    #endif
    }
    
     
  13. 52
    74
    67
    akuhak

    akuhak Member

    Joined:
    Jul 4, 2017
    Messages:
    52
    Likes Received:
    74
    Trophy Points:
    67
    I receive such an error in my enivronment:

    [​IMG]
    the error is the same if use openssl from apt repository, or if I compile it from scratch. Segmentation error I receive if iI use gcc++-9
     
  14. 184
    318
    122
    uyjulian

    uyjulian Developer

    Joined:
    May 27, 2017
    Messages:
    184
    Likes Received:
    318
    Trophy Points:
    122
    Gender:
    Male
    You may need to do something like this:
    Code:
    std::string getKeyStorePath()
    {
       return "/hardcoded/path/to/PS2KEYS.dat";
    }
    
     
    Algol, TnA and akuhak like this.
  15. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland
    Speaking of which: could You modified this code to bind key file within application? To not seek any file anywhere with them.
     
  16. 184
    318
    122
    uyjulian

    uyjulian Developer

    Joined:
    May 27, 2017
    Messages:
    184
    Likes Received:
    318
    Trophy Points:
    122
    Gender:
    Male
    I don't think that is a good idea because it is grounds for DMCA takedown (like what happened with ps3mca-tool)
     
  17. 2,418
    2,405
    372
    Berion

    Berion Developer

    Joined:
    Feb 3, 2015
    Messages:
    2,418
    Likes Received:
    2,405
    Trophy Points:
    372
    Gender:
    Male
    Location:
    Poland
    Not as commit, just for private usage.
     

Share This Page