PS2 kelftool and ELF headers

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!
 
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!
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
 
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:
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.
 
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)?
 
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.
 
  • Like
Reactions: TnA
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
 
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. ^^
 
Are you getting segmentation fault in function "getKeyStorePath"? You may need to hardcode the path due to C++ scoping rules.
 
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
}
 
I receive such an error in my enivronment:

PAJti9U.png

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
 
Speaking of which: could You modified this code to bind key file within application? To not seek any file anywhere with them.
 
I don't think that is a good idea because it is grounds for DMCA takedown (like what happened with ps3mca-tool)
 
Not kernelelf, but KryptoELF!

Bringing back this discussion. Just a thought: ^^

Isn't Kermit is the codename of PSP IPL? Many stuff related to HDD and DESR was adopted in PSP so maybe KELF stands for Kermit ELFs?
 
It is possible to run HDD OSD by FHDB or uLE/wLE? I have tried decrypt "OSDSYS_A.XLF" using kelftool from SUDCv4 from HDD Utility Disk v1.10 and to add standard ELF header but it displays me error about "something m_struct".

Well, would be nice to keep FHDB and launching HDD OSD on demand, because hosd alone is kind a useless. ;p I have unpacked this PAK file and put stuff in proper place on proper partitions and works nice but well, FHDB is much more handy in daily use.

BTW: Does FMCB/FHDB can launch KELFs in the first place?


@krHACKen @sp193
 

Similar threads

Back
Top