- 精华
- 0
- 帖子
- 71
- 威望
- 0 点
- 积分
- 111 点
- 种子
- 0 点
- 注册时间
- 2004-8-27
- 最后登录
- 2024-11-4
|
搬运一下关于破解SONY PS3-GAME游戏授权系统国外大神的详细分析含PSN游戏
原帖地址:http://www.ps3news.com/forums/ps3-cfw-mfw/psn-games-decrypted-ps3-custom-firmware-3-55-duplex-121017.html
转载:大老
原帖标题:PSN Games Decrypted for PS3 Custom Firmware 3.55 by DUPLEX!
内容:
Today PlayStation 3 scene release group DUPLEX, who recently leaked the full PS3 3.40 SDK which was then followed by the PS3 3.60 SDK, have now released a bunch of PSN games decrypted for PS3 Custom Firmware 3.55 and 3.41 users!
Below is one of the PS3 NFO files for Alien.Breed.Impact.PSN.PS3-DUPLEX.nfo from their PlayStation Network game releases along with an ongoing list of NPDRM decrypted titles, as follows:
Release Info: Alien BreedT Impact is an explosive science fiction arcade-shooter that resurrects a much revered franchise with an epic story, swarms of highly intelligent alien enemies, high-impact weapons, highly detailed and rich environments; all implemented with superb technology in a state-of-the-art gaming experience.
Notes: Since no scene group managed yet, we thought it's time to work on some PSN games to give everyone something to play for CFW 3.55. Fully decrypted .elfs are included as proof and of course for educational purposes
1.) copy files to FAT32 USB Key/USB Disk
2.) install game *DUPLEX.*.Install.pkg
3.) install patch *DUPLEX.*.Patch.vX.XX.pkg if any
4.) install crack *DUPLEX.*.Crack.pkg
5.) play
• Watchmen.The.End.is.Nigh.Part.2.PSN.PS3-DUPLEX PlayStation
• Watchmen.The.End.is.Nigh.Part.1.PSN.PS3-DUPLEX PlayStation
• UNO.PSN.PS3-DUPLEX PlayStation
• Super.Stardust.HD.PSN.PS3-DUPLEX PlayStation
• Sonic.The.Hedgehog.4.Episode.1.PSN.PS3-DUPLEX PlayStation
• Puzzelgeddon.PSN.PS3-DUPLEX PlayStation
• Plants.vs.Zombies.PSN.PS3-DUPLEX PlayStation
• PixelJunk.Monsters.PSN.PS3-DUPLEX PlayStation
• Limbo.PSN.PS3-DUPLEX PlayStation
• Spare.Parts.PSN.PS3-DUPLEX PlayStation
• Ricochet.HD.PSN.PS3-DUPLEX PlayStation
• Galaga.Legions.DX.PSN.PS3-DUPLEX PlayStation
• Savage.Moon.PSN.PS3-DUPLEX PSP
• Dream.Chronicles.PSN.PS3-DUPLEX PSP
• Deadliest.Warrior.The.Game.PSN.PS3-DUPLEX PlayStation
• Marvel.vs.Capcom.2.PSN.PS3-DUPLEX PlayStation
• Earthworm.Jim.HD.PSN.PS3-DUPLEX PlayStation
• Deadliest.Warrior.Legends.PSN.PS3-DUPLEX PlayStation
• PacMan.Championship.Edition.DX.PSN.PS3-DUPLEX PlayStation
• Critter.Crunch.PSN.PS3-DUPLEX PlayStation
• Costume.Quest.PSN.PS3-DUPLEX PlayStation
• Castle.Crashers.PSN.PS3-DUPLEX PlayStation
• Bomberman.Ultra.PSN.PS3-DUPLEX PlayStation
• BloodRayne.Betrayal.PSN.PS3-DUPLEX PlayStation
• Blast.Factor.PSN.PS3-DUPLEX PlayStation
• Beyond.Good.and.Evil.HD.PSN.PS3-DUPLEX PlayStation
• Bejeweled.2.PSN.PS3-DUPLEX PlayStation
• Alien.Breed.3.Descent.PSN.PS3-DUPLEX PlayStation
• Alien.Breed.2.Assault.PSN.PS3-DUPLEX PlayStation
• Alien.Breed.Impact.PSN.PS3-DUPLEX PlayStation
Lets hope for more coming, and feel free to post links to free file-sharing sites for the modded PKG files to download below! Here are some of the initial download links courtesy of http://www.ps3iso.com/showpost.php?p=431716&postcount=1:
IF YOU ALREADY HAD A DEMO OF ANY OF THOSE GAMES, or LOST THE ACTIVATION/LICENSE, Just delete the installed PSN game first (your savegame should be intact) and reinstall the Duplex version as a clean install. Should work!
PS: the .elf file is useless. Delete it if you want! It's only for those who want to understand how it works.
Limbo PSN PS3-DUPLEX
Size: 98 MB
http://www.fileserve.com/file/kBva9Q...PS3-DUPLEX.rar
http://www.filejungle.com/f/MuUT9u/L...PS3-DUPLEX.rar
http://www.filesonic.com/file/221159...PS3-DUPLEX.rar
Castle.Crashers.PSN.PS3-DUPLEX
Size: 161 MB
http://filejungle.com/f/JVftbP/Castl...PS3-DUPLEX.rar
http://fileserve.com/file/wXtzN6g/Ca...PS3-DUPLEX.rar
http://depositfiles.com/files/a9i2wl...PS3-DUPLEX.rar
http://www.filesonic.com/file/221128...PS3-DUPLEX.rar
http://wupload.com/file/210708642/Ca...PS3-DUPLEX.rar
Costume.Quest.PSN.PS3-DUPLEX
Size: 406 MB
http://filejungle.com/f/ccsGQj/Costu...PS3-DUPLEX.rar
http://fileserve.com/file/PK7Xndc/Co...PS3-DUPLEX.rar
http://depositfiles.com/files/b0yfpo...PS3-DUPLEX.rar
http://www.filesonic.com/file/221131...PS3-DUPLEX.rar
http://wupload.com/file/210712952/Co...PS3-DUPLEX.rar
Beyond.Good.and.Evil.HD.PSN.PS3-DUPLEX
Size: 1514 MB
http://filejungle.com/f/Pb4M6g/Beyon...PLEX.part1.rar
http://filejungle.com/f/sZbaJj/Beyon...PLEX.part2.rar
http://fileserve.com/file/ZpjajKV/Be...PLEX.part1.rar
http://fileserve.com/file/dxVWkzF/Be...PLEX.part2.rar
http://depositfiles.com/files/ak9x4r...PLEX.part1.rar
http://depositfiles.com/files/5lq3k3...PLEX.part2.rar
http://www.filesonic.com/file/221122...PLEX.part1.rar
http://www.filesonic.com/file/221122...PLEX.part2.rar
http://www.fileserve.com/file/Tt9Wv4...PLEX.part1.rar
http://www.fileserve.com/file/YQbYzr...PLEX.part2.rar
http://www.wupload.com/file/21070800...PLEX.part1.rar
http://www.wupload.com/file/21070740...PLEX.part2.rar
Ricochet.HD.PSN.PS3-DUPLEX
Size: 337 MB
http://fileserve.com/file/NCmeZc4/Ri...PS3-DUPLEX.rar
http://depositfiles.com/files/pz22qi...PS3-DUPLEX.rar
http://www.filesonic.com/file/221149...PS3-DUPLEX.rar
http://wupload.com/file/210733555/Ri...PS3-DUPLEX.rar
Plants.vs.Zombies.PSN.PS3-DUPLEX
Size: 109 MB
http://filejungle.com/f/bCpPj6/Plant...PS3-DUPLEX.rar
http://fileserve.com/file/ScaJMhv/Pl...PS3-DUPLEX.rar
http://depositfiles.com/files/6n1hpa...PS3-DUPLEX.rar
http://www.filesonic.com/file/221221...PS3-DUPLEX.rar
http://wupload.com/file/210849120/Pl...PS3-DUPLEX.rar
Galaga.Legions.DX.PSN.PS3-DUPLEX
Size: 136 MB
http://fileserve.com/file/qsjjvDD/Ga...PS3-DUPLEX.rar
http://depositfiles.com/files/lk15td...PS3-DUPLEX.rar
http://www.filesonic.com/file/221146...PS3-DUPLEX.rar
Dream.Chronicles.PSN.PS3-DUPLEX
Size: 148 MB
http://fileserve.com/file/P9kRqrN/Dr...PS3-DUPLEX.rar
http://depositfiles.com/files/vs91qj...PS3-DUPLEX.rar
http://www.filesonic.com/file/221141...PS3-DUPLEX.rar
Deadliest.Warrior.The.Game.PSN.PS3-DUPLEX
Size: 1075 MB
http://filejungle.com/f/cmuvVj/Deadl...PLEX.part1.rar
http://filejungle.com/f/se3jQM/Deadl...PLEX.part2.rar
http://fileserve.com/file/AyGCMvZ/De...PLEX.part1.rar
http://fileserve.com/file/F3vMz2B/De...PLEX.part2.rar
http://depositfiles.com/files/jvpdrq...PLEX.part1.rar
http://depositfiles.com/files/o6s8ts...PLEX.part2.rar
http://www.filesonic.com/file/221146...PLEX.part1.rar
http://www.filesonic.com/file/221140...PLEX.part2.rar
Deadliest.Warrior.Legends.PSN.PS3-DUPLEX
Size: 1717 MB
http://filejungle.com/f/xV6h35/Deadl...PLEX.part1.rar
http://filejungle.com/f/6YKM7N/Deadl...PLEX.part2.rar
http://fileserve.com/file/5zgx3Vb/De...PLEX.part1.rar
http://fileserve.com/file/mnGj9R7/De...PLEX.part2.rar
http://depositfiles.com/files/ayrjcn...PLEX.part1.rar
http://depositfiles.com/files/bltgvi...PLEX.part2.rar
http://www.filesonic.com/file/221190...PLEX.part1.rar
http://www.filesonic.com/file/221141...PLEX.part2.rar
Marvel.vs.Capcom.2.PSN.PS3-DUPLEX
Size: 203 MB
http://filejungle.com/f/hmmfpF/Marve...PS3-DUPLEX.rar
http://fileserve.com/file/8knJ5Km/Ma...PS3-DUPLEX.rar
http://depositfiles.com/files/sn51bi...PS3-DUPLEX.rar
http://www.filesonic.com/file/221139...PS3-DUPLEX.rar
Earthworm.Jim.HD.PSN.PS3-DUPLEX
Size: 240 MB
http://filejungle.com/f/2qK7CV/Earth...PS3-DUPLEX.rar
http://fileserve.com/file/QMQ6bfB/Ea...PS3-DUPLEX.rar
http://depositfiles.com/files/cekos5...PS3-DUPLEX.rar
http://www.filesonic.com/file/221136...PS3-DUPLEX.rar
http://wupload.com/file/210713964/Ea...PS3-DUPLEX.rar
PacMan.Championship.Edition.DX.PSN.PS3-DUPLEX
Size: 251 MB
http://filejungle.com/f/nUyPqP/PacMa...PS3-DUPLEX.rar
http://fileserve.com/file/47pbxyu/Pa...PS3-DUPLEX.rar
http://depositfiles.com/files/v9eofj...PS3-DUPLEX.rar
http://www.filesonic.com/file/221136...PS3-DUPLEX.rar
http://wupload.com/file/210715625/Pa...PS3-DUPLEX.rar
Critter.Crunch.PSN.PS3-DUPLEX
Size: 447 MB
http://filejungle.com/f/fmseG2/Critt...PS3-DUPLEX.rar
http://fileserve.com/file/6pYWH9D/Cr...PS3-DUPLEX.rar
http://depositfiles.com/files/wbmu1b...PS3-DUPLEX.rar
Bomberman.Ultra.PSN.PS3-DUPLEX
Size: 72 MB
http://filejungle.com/f/f7PcMs/Bombe...PS3-DUPLEX.rar
http://fileserve.com/file/xRaVtp4/Bo...PS3-DUPLEX.rar
http://depositfiles.com/files/vq1ok0...PS3-DUPLEX.rar
http://www.filesonic.com/file/221127...PS3-DUPLEX.rar
http://wupload.com/file/210707267/Bo...Ultra.PSN.PS3-
DUPLEX.rar
BloodRayne.Betrayal.PSN.PS3-DUPLEX
Size: 972 MB
http://filejungle.com/f/FrxvX3/Blood...PS3-DUPLEX.rar
http://fileserve.com/file/xWKUSgv/Bl...PS3-DUPLEX.rar
http://depositfiles.com/files/kshfnn...PS3-DUPLEX.rar
http://www.filesonic.com/file/221122...PS3-DUPLEX.rar
http://www.filesonic.com/file/221121...PS3-DUPLEX.rar
http://www.fileserve.com/file/T4SD7Tq
http://www.wupload.com/file/210708000
Alien.Breed.3.Descent.PSN.PS3-DUPLEX
Size: 1701 MB
http://filejungle.com/f/JjDYSp/Alien...PLEX.part1.rar
http://filejungle.com/f/zy4rKV/Alien...PLEX.part2.rar
http://fileserve.com/file/v2JejjJ/Al...PLEX.part1.rar
http://fileserve.com/file/UkSDcE8/Al...PLEX.part2.rar
http://depositfiles.com/files/fhxxzb...PLEX.part1.rar
http://depositfiles.com/files/o5mpmq...PLEX.part2.rar
Blast.Factor.PSN.PS3-DUPLEX
Size: 276 MB
http://filejungle.com/f/AN76Wm/Blast...PS3-DUPLEX.rar
http://fileserve.com/file/y3hzgXQ/Bl...PS3-DUPLEX.rar
http://depositfiles.com/files/ilgk72...PS3-DUPLEX.rar
http://www.filesonic.com/file/221115...PS3-DUPLEX.rar
Bejeweled.2.PSN.PS3-DUPLEX
Size: 49 MB
http://filejungle.com/f/z8mJjy/Bejew...PS3-DUPLEX.rar
http://fileserve.com/file/wtQ92vP/Be...PS3-DUPLEX.rar
http://depositfiles.com/files/gax1h7...PS3-DUPLEX.rar
http://www.filesonic.com/file/221111...PS3-DUPLEX.rar
http://wupload.com/file/210692333/Be...PS3-DUPLEX.rar
Alien.Breed.Impact.PSN.PS3-DUPLEX
Size: 1199 MB
http://filejungle.com/f/QWy4x2/Alien...PLEX.part1.rar
http://filejungle.com/f/yXTu5J/Alien...PLEX.part2.rar
http://fileserve.com/file/fq8zZve/Al...PLEX.part1.rar
http://fileserve.com/file/vUJBDDR/Al...PLEX.part2.rar
http://depositfiles.com/files/dja340...PLEX.part1.rar
http://depositfiles.com/files/me8c1d...PLEX.part2.rar
http://www.filesonic.com/file/221134...PLEX.part1.rar
http://www.filesonic.com/file/221113...PLEX.part2.rar
Alien.Breed.2.Assault.PSN.PS3-DUPLEX
Size: 1382 MB
http://filejungle.com/f/e5pta2/Alien...PLEX.part1.rar
http://filejungle.com/f/BzV8Rr/Alien...PLEX.part2.rar
http://fileserve.com/file/CpbdGys/Al...PLEX.part1.rar
http://fileserve.com/file/sNw5DAr/Al...PLEX.part2.rar
http://depositfiles.com/files/25ihhc...PLEX.part1.rar
http://depositfiles.com/files/oxpy21...PLEX.part2.rar
Spare.Parts.PSN.PS3-DUPLEX
Size: 1153 MB
http://filejungle.com/f/R9AZGX/Spare...PLEX.part1.rar
http://filejungle.com/f/hKbZnj/Spare...PLEX.part2.rar
http://fileserve.com/file/WjuZkX3/Sp...PLEX.part1.rar
http://fileserve.com/file/VNytxzW/Sp...PLEX.part2.rar
http://depositfiles.com/files/z3txri...PLEX.part1.rar
http://depositfiles.com/files/0ij459...PLEX.part2.rar
Puzzelgeddon.PSN.PS3-DUPLEX
Size: 180 MB
http://filejungle.com/f/T2fwqz/Puzze...PS3-DUPLEX.rar
http://fileserve.com/file/uxJk9wM/Pu...PS3-DUPLEX.rar
http://depositfiles.com/files/q3rm3i...PS3-DUPLEX.rar
UNO.PSN.PS3-DUPLEX
Size: 262 MB
http://filejungle.com/f/U97GHj/UNO.PSN.PS3-DUPLEX.rar
http://fileserve.com/file/Jax2tcx/UN...PS3-DUPLEX.rar
http://depositfiles.com/files/rk515c...PS3-DUPLEX.rar
http://www.filesonic.com/file/221156...PS3-DUPLEX.rar
http://wupload.com/file/210790811/UN...PS3-DUPLEX.rar
Super.Stardust.HD.PSN.PS3-DUPLEX
Size: 520 MB
http://filejungle.com/f/GrdETy/Super...PS3-DUPLEX.rar
http://fileserve.com/file/SR5JYK5/Su...PS3-DUPLEX.rar
http://depositfiles.com/files/7za9l1...PS3-DUPLEX.rar
http://wupload.com/file/210790296/Su...PS3-DUPLEX.rar
Sonic.The.Hedgehog.4.Episode.1.PSN.PS3-DUPLEX
Size: 204 MB
http://filejungle.com/f/Qwb9UP/Sonic...PS3-DUPLEX.rar
http://fileserve.com/file/3w2aqVR/So...PS3-DUPLEX.rar
http://depositfiles.com/files/q6ony1...PS3-DUPLEX.rar
http://wupload.com/file/210854615/So...PS3-DUPLEX.rar
Savage.Moon.PSN.PS3-DUPLEX
Size: 567 MB
http://filejungle.com/f/EdqDvg/Savag...PS3-DUPLEX.rar
http://fileserve.com/file/Yc2XAZj/Sa...PS3-DUPLEX.rar
http://depositfiles.com/files/2hva00...PS3-DUPLEX.rar
Watchmen.The.End.is.Nigh.Part.1.PSN.PS3-DUPLEX
Size: 1286 MB
http://filejungle.com/f/sXfVCn/Watch...PLEX.part1.rar
http://filejungle.com/f/3FfmhZ/Watch...PLEX.part2.rar
http://fileserve.com/file/gQ97h22/Wa...PLEX.part1.rar
http://fileserve.com/file/MKTmGxK/Wa...PLEX.part2.rar
http://depositfiles.com/files/yaqxu6...PLEX.part1.rar
http://depositfiles.com/files/3wadnd...PLEX.part2.rar
http://www.filesonic.com/file/221159...PLEX.part2.rar
http://wupload.com/file/210793415/Wa...PLEX.part1.rar
http://wupload.com/file/210790244/Wa...PLEX.part2.rar
Watchmen.The.End.is.Nigh.Part.2.PSN.PS3-DUPLEX
Size: 830 MB
http://filejungle.com/f/X49vgc/Watch...PS3-DUPLEX.rar
http://fileserve.com/file/AN2rETm/Wa...PS3-DUPLEX.rar
http://depositfiles.com/files/axdbyp...PS3-DUPLEX.rar
http://www.filesonic.com/file/221265...PS3-DUPLEX.rar
From JuanNadie aka John Doe comes details on the PlayStation 3 NPDRM Self Algorithm below, as follows:
PS3 NPDRM Self Algorithm
THIS DOES NOT ALLOW TO OBTAIN 3.60+ keys, nor piracy as you require the rif, act.dat and IDPS.
On NPDRM self decryption all the security levels of the PS3 are involved: user space (vsh), kernel space(lv2), hypervisor( lv1) and isolated SPU (metldr + appldr)
The process start on vsh.elf...
VSH
Once the vsh detects that user is trying to start a self, it looks for the appinfo header type. If the type is 8, then the control digest element type 3 (NPD element) is located. From this NPD header the vsh gets the license type (free, local or network license).
If a free content(type 3) is detected then a generic klicense will be use for further steps (go to LV2). That klicensee is already public (see geohot npdrm_omac_key_1).
Code:
npdrm_omac_key1 : 72F990788F9CFF745725F08E4C128387 # ps3publictools/include/oddkeys.h
npdrm_omac_key2 : 6BA52976EFDA16EF3C339FB2971E256B # ...
npdrm_omac_key3 : 9B515FEACF75064981AA604D91A54E97 # ...
However if a paid content is to be loaded the vsh loads the act.dat and the rif associated to the content (if local it will locate a file with the same titleid on NPD element, if remote it will download to vsh process memory)
Then the signature is checked (last 0x28 bytes of both RIF and act.dat). The curves used are on vsh.self. It is a 3 element table, having the first curve nulled. The curve index for rif/act is 2. The curve values are negated as in the apploader and has the following structure:
Code:
struct curve {
uint8_t p[0x14];
uint8_t a[0x14];
uint8_t b[0x14];
uint8_t N[0x14];
uint8_t Gx[0x14];
uint8_t Gy[0x14];
}
If the curve checks then vsh will process the rif:
Code:
struct rif {
uint8_t unk1[0x10]; //version, license type and user number
uint8_t titleid[0x30]; //Content ID
uint8 padding[0xC]; //Padding for randomness
uint32_t actDatIndex; //Key index on act.dat between 0x00 and 0x7F
uint8 key[0x10]; //encrypted klicensee
uint64_t unk2; //timestamp??
uint64_t unk3; //Always 0
uint8_t rs[0x28];
};
struct ACTDAT {
uint8_t unk1[0x10]; //Version, User number
uint8_t keyTable[0x800]; //Key Table
......
uint8_t signature[0x28];
}
Using the RIF_KEY it will obtain the actdatIndex:
Code:
AES_KEY rifKey;
int result = AES_set_decrypt_key(RIF_KEY, 0x80, &rifKey);
AES_decrypt(&rif->padding, &rif->padding, &rifKey);
And finally having the actDat key index the execution pass to LV2 syscall 471
LV2
Lv2 is accessed using syscall471 which haves the following syntax:
Code:
int syscall_471(uint32_t type, char* titleID, void* klicensee, uint8_t* actdat, uint8_t* rif, int32_t licenseType, uint8_t* magicVersion);
The function has different parameters depending if the content is debug, free or paid:
Code:
FREE: syscall471(npd.type, &npd.titleID, freeklicensee, NULL, NULL, npd.license, &npd);
PAID: syscall471(npd.type, &npd.titleID, NULL, &actdat.keyTable[rif.actDatIndex], &rif.key, npd.license, &npd);
The lv2 keeps a memory table with contentID and the associated key. When it receives a free content (r5 is not null) then copies the titleID and the klicensee to the table. For a paid content the rif.key is converted to the klicensee using:
Code:
AES_KEY IDPSKey, ConstKey, ActDatKey;
uint8_t encrConst[0x10];
uint8_t decryptedActDat[0x10];
uint8_t klicensee[0x10];
int result = AES_set_encrypt_key(&IDPSVariation, 0x80, &IDPSKey);
AES_encrypt(&CONSTACTDAT, &encrConst, &IDPSKey);
result = AES_set_decrypt_key(&encrConst,0x80,&ConstKey);
AES_decrypt(actDat,&decryptedActDat,&ConstKey);
result = AES_set_decrypt_key(&decryptedActDat,0x80,&ActDatK ey);
AES_decrypt(rif,&klicensee,&ActDatKey);
where CONSTACTDAT is a constant value on lv2, IDPSVaritaion appears to be IDPS (not checked but DRM_Manager_initialize (see graf_chokolo's "bible") to something with the same structure), actdat are the 0x10bytes selected by rif keyIndex, and rif is rif.key (bytes 0x50-0x5f).
Once transformed it is stored on memory table... I haven't check further steps on vsh nor lv2 so perhaps there are further transformations on the paid case (NOT FOR THE FREE AS I HAVE DECRYPTED THOSE) so we are jumping directly to the appldr
AppLdr
As you can see from graf_chokolo payloads a parameter is passed on spu_args.field60. That parameter is the previously stored klicensee.
However this key must be transformed (again) even for the free case. The transformation is:
Code:
uint8_t decryptedKLicensee[0x10]
AES_KEY KLicenseeKey
int result = AES_set_decrypt_key(&KLicenseeDecryptKey,0x80,&KLI CENSEEKEY);
AES_decrypt(klicensee,&decryptedKLicensee,&KLicens eeKey);
EY is another key located inside the apploader and klicensee is the parameter.
Then we can finally remove the NPDRM layer using:
Code:
AES_KEY key;
uint8_t iv[0x10];
memset(&iv[0],0,0x10);
int result = AES_set_decrypt_key(&KLicenseeDecryptKey,0x80,&key );
AES_cbc_encrypt(self + self->metaoffset + 0x20, self + self->metaoffset + 0x20,0x40,&key,&iv,0);
Once that layer is removed we proceed as normal:
• Decrypt using AESCBC256 with the NPDRM keys to obtain the metadata keys
• Decrypt using AESCTR128 the data sha, hmac, iv keys
• Decrypt the data.
First of all, I want to congratulate Euss of ps3devwiki on finding the klicensee decrypt key and provide a proof of concept of the AppLoder part of the algorithm. Check ps3devwiki.com/index.php?title=Talk:SELF_File_Format_and_Decrypti on
Download: PS3 AppLDR/NPDRM 0.***.31 Rev 0x01 (2.39 KB) / UnSelf2_keys (app-priv-102f and app-priv-356) (168 Bytes) by RikuKH3
KLicenseeDecryptKey is located in appldr twice, e.g.
1.00:
Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000187C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000187D0 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
000187E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000187F0 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
3.15:
Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00018EB0 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
00018EC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00018ED0 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
00018EE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
3.55:
Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00019730 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
00019740 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00019750 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
00019760 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
3.56:
Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0001F920 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
0001F930 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F940 F2 FB CA 7A 75 B0 4E DC 13 90 63 8C CD FD D1 EE òûÊzu°NÜ..cŒÍýÑî
0001F950 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Now you have the tools to decrypt all free executable content. Euss they key is not duplicated... there are two cases that lead to the same (similar to the keys, two cases so two repeated tables).
Some of you asked what this algorithm is for. It has several use from backing up PSN games so they can be used with/without license (some countries allow backups, but NEVER sharing copyrighted material...) or use game updates on lower firmwares (some updates are NPDRM so they could not be decrypted and downgraded). I don't know if DUPLEX used this method or if they replaced the data with debug versions as some implied...
Also, it can be use is to modify geohot's make_self_npdrm to use non static keys for encoding. I don't know if that would be enough to make a self runnable on 3.56+ firmware. However it is a step on the right direction (I think extra modifications are required). If someone knows which parts of the self is whitelisted it would be an interesting addition to the thread. Sony was publishing 3.55 after 3.56 went online so I really interested to see which part of the SELF was whitelisted.
Others asked for the keys. I can not provide them nor functional code to avoid being sued... Graf and geohot were sued for providing the keys and/or functional code.
However, I can provide a tip on getting the RIF key.... once decrypted bytes 0x40 to 0x4F should be xx xx xx xx xx xx xx xx xx xx xx xx 00 00 00 aa where x is random and aa is a number between 0x00 and 0x7F. It is located on the VSH.elf (remember that PPC64 has 8 byte aligment). That is a plaintext attack + dictionary(vsh). You don't need the curves as you can not sign rif nor act.dat (You can only check that file is valid). And the vsh keys can be easily find... graf chokolo called IDPS as device_id_ptr.... and the CONST is very near on code execution...
To yolbulduran: That is a piracy related question. In addition you have published confidential info, which anyone who does RCE should avoid (I do not have the SDK). The answer is NO. Why?. See this code:
Code:
ret = sceNpDrmVerifyUpgradeLicense("FAKE_CONTENT_TO_DETECT_CFW");
if(ret == 0){
banConsole();
print("CFW detected. Game will exit");
exit(-1);
}
Code:
ret = sceNpDrmVerifyUpgradeLicense("REAL_CONTENT");
if (ret == 0) {
int fd = openEncryptedContent("REAL_CONTENT.edat",......,keyForFile,sizeof(KeyForFile));
if (fd > 0) {
//Do things
}
}
First part is an example of how a developers can easily catch that modification and stop execution making it dangerous (could get a ban!!!). You modification says that the console has access to a fake content, which only CFW will have. When patching code the modification should be done only to the case you want to fix. That modification should go on the executable not on npd libraries. That way we do not patch the first verify but we will patch the second...
The second part is the real reason why it wont work... you REQUIRE the rif for opening the edat. The rif holds the klicensee for both SELF and EDAT. In fact I assume that the klicensee follows the same transformation upto the apploader. That key that you see on the command it is only used to check the HMAC on the NPD element (see geohot make_self_npdrm omac calculations)
For executable the problem is similar as when trying to run another PPU executable the program will finish and ask the vsh to run the other process which will undergo the full decryption algorithm... again you need the rif.
But... what will happen if we decrypt the paid edat/SELF using the rif and then resign and encrypt as a free content before executing the code??? (Assuming we can sign edat)
WE CAN SIGN EXECUTABLES UP TO 3.55 THANKS TO FAIL0VERFLOW'S EPIC FAIL... I think people do not really understands what that means...
From granberro: Congratulations and thanks for sharing JuanNadie. Regarding EDAT files, IMHO their encryption is FW version independent, at least for the free content. I have changed geohot's make_self_npdrm to encrypt elfs using a given keypair rather than the static one.
Using that tool and unself2 I have managed create and install LBP2 updates 1 to 4 on a 3.41 PS3. Those updates contains EDAT files and were decrypted by the game flawlessly.
I don't know if it is ok to post links to those pkgs. The npdrm diff (just) the important stuff is:
Code:
+#ifdef NPDRM2
+ memcpy(&md_header, KEY(keypair), sizeof(md_header));
+#endif
-----------------
+#ifdef NPDRM2
+ AES_set_encrypt_key(KEY(erk), 256, &aes_key);
+ memcpy(iv, KEY(iv), 16);
+ AES_cbc_encrypt(&output_self_data[metadata_offset], &output_self_data[metadata_offset], 0x40, &aes_key, iv, AES_ENCRYPT);
+ u8 d_klic[0x10];
+ AES_set_decrypt_key(KLicenseeDecryptKey, 128, &aes_key);
+ AES_decrypt(npdrm_omac_key1, d_klic, &aes_key);
+ AES_set_encrypt_key(d_klic, 128, &aes_key);
+ memset(iv, 0, sizeof iv);
+ AES_cbc_encrypt(&output_self_data[metadata_offset], &output_self_data[metadata_offset], 0x40, &aes_key, iv, AES_ENCRYPT);
+#else
memcpy(&output_self_data[metadata_offset], KEY(keypair_e), sizeof(md_header));
Hope it helps.
From JuanNadie: Actually an EDAT has several keys. One is in the SELF, others are at the rif and others on firmware. That an EDAT works on lower firmware only proves that the firmware has those keys.
BTW I have tricked the PS3 into decrypt an EDAT (Buzz). The procedure involves knowing how the NPD element is used (most of this is already published).
Code:
struct {
uint32_t magic;
uint32_t unknown2;
uint32_t license; /* 1 network, 2 local, 3 free */
uint32_t type; /* 1 exec, 21 update */
uint8_t content_id[48];
uint8_t digest[16];
uint8_t titlefilenameHash[16];
uint8_t headerHash[16];
uint64_t unknown3;
uint64_t unknown4;
} npdrm;
The NPD has 3 different hashes:
• The first (digest) is a hash of the decrypted data. I don't know the algorithm nor if it is checked.
• The second is a CMAC. The key is npdrm_omac_key3, and the message is the titleID (0x30 bytes) concat to the filename (excluding path and case sensitive),
• The third is again a CMAC. This time the message is the whole NPD from NPD magic to the second hash both included. The key for SELFs launched from the VSH is npdrm_omac_key1 xored with npdrm_omac_key2
But for the rest (Selfs executed inside a program and EDAT) instead of using npdrm_omac_key1 another key is used. That key is called the klicensee (however as that name is already used I would call it devklic (developer klicensee),
That key is selected randomly by the developer(activision, ea, ubisoft, square...) and it is a parameter used when creating a pkg. So for EDAT the key for the third hash is devklic xored with npdrm_omac_key2.
If we are going to recrypt an EDAT we need that key. There are several procedures to obtain it:
• Decrypt the SELF and use RCE to get it. We'll need an idc that locates the call. Very slow, tricky, requires large knowledge but always work.
• Hook the call that opens EDAT. Then we retrieve it on parameter r3. Faster, requires modifying the firmware. Always work
• Brute force it: Decrypt the self and try every combination of 16 sequential bytes on the file. I obtained using this method the key on Buzz and LBP. It faster than RCE but it does not always work (the key could be in other file or obfuscated).
I repeat we will need that key to encrypt an EDAT.
We SONY uses this key? To avoid the following exploit?:
• Obtain the devklic.
• On a PS3 where the EDAT is authorized write a program with the following command;
Code:
sceNp....Open(devklic, "PATH_TO_FILE",READ_ONLY,fd,NULL,0);
That will create a file descriptor. The read of it will be on clear... and we can then write it to an output file.
How I think this works? Well, you provide the correct klicense, so the system will validate the NPD and send a request to LV2 to set the decryption key (This would be related to rif for paid or to the devklic if free). Then when reading if the LV2 Will ask the appldr to decrypt it).... Note that seek works so probably the decryption can be made by blocks.
BTW something similar was done on PSP.
How can we use this?
• First is good to have the plain text of something you0re trying to reverse so for devs it could be useful to reverse EDAT algorithm
• Second you can replace the original file and patch the EBOOT to not use encryption.
• Third you can create a debug EDAT and path lv2 to accept debug files.
However IMHO any warez release that uses those tricks should be NUKED as that is not the correct procedure (that would be reencrypt the EDAT as free).
Other things:
• The first hash of NPD needs to be obtained
• The first 0x80 encrypted bytes of an EDAT (0x90-0x10F) contains a key for decrypting the rest of the file. I think that key is constant for the rest of the file. Reason: the 2 EDAT I decrypted from Buzz has the same contain... which means hash1 is the same (2 and 3 are different cause the filename is different), but the encrypted content in the metadata section changes. Perhaps a signature but I think there is a different key there (the data also changes)
granberro Buen trabajo. I saw your work at elotrolado allowing the use of non static keys on a NPDRM.
mathieulh thanks for the compliments on type 2 NPDRM. I also think that someone should modify make_self_npdrm to make SELFs that work "at least" on 3.55 official firmware...
I haven't fully reversed the EDAT algorithm (I’m missing bytes from 0xB0 to 0xFF) but there is enough info for a post. The explanation is for those with flag (offset 0x80-0x83) equals to 0xC which is a normal EDAT. For others values minor changes should be made. Let's begin.
USER SPACE: (Probably incomplete (enough for decryption), most of it is guessed) On previous post I mentioned the command useds by developers to open/read an EDAT. That command has 3 parts:
• Verify: This parts verifies the NPD element by checking that user is authorized to open the file (using the devklic). In addition it calls LV2 to create an entry in the memory (probably using syscall471) so for further steps it will use the devklic (free) or the decrypted rif key (paid) (see SELF algorithm). I’ll call this rifkey on the rest of the document.
• Open the file: This will call kernel space. Performs several checks and creates an entry on another table.
• Read: It also calls LV2, which will decrypt and send data back.
KERNEL SPACE:
When an open request is received:
• Read the first 0x100 bytes of the file.
• Validates first 0xA0 bytes on EDAT. This uses appldr with the following execution (see below):
• Single execution
• Encrypted arguments
• CMAC. Key: rifkey, expectedHash: data at 0xA0-0xAF
• No Encryption erk:null,riv:null
Validates metadatasections. Again uses appldr:
• Multi execution. Blocks upto 0xFC00.
• Encrypted arguments
• CMAC. Key: rifkey, expectedHash:data at 0x90-0x9F
• No Encryption: erk:null, riv:null
Once the NPD is validated (We have validated header upto 0xAF and the metadatasections( which validate the data itself)) an entry on a memory table is created, the entry created by syscall471 is erased and returns. I’ll call this the EDATEncryptionDataTable. This table has 10 entries (remember the limitation of simultaneous files opened??...). Each entry has the following structure:
Code:
typedef struct {
uint64_t fileDescriptor;
uint64_t offset;
uint64_t fileLen;
uint32_t flag;
uint32_t blockSize;
uint32_tnumBlocks;
uint8_t blockBase[0x0C];
uint8_t devklic[0x10];
uint8_t digest[0x10];
}EDATEncryptionData ;
-fileDescriptor: The file descriptor
-offset: An additional offset to calculate the position of the metadataSection. Origin unknown. Values seen 0
-File len: Length of the uncompressed data. Copied from EDAT offset 0x88-0x8F
-flag: Flags required to process the data. Copied from EDAT offset 0x80-0x83. Some flags are:
Code:
0x80000000: Debug
0x01000000: SDAT… for those rifkey is calculated differently. Algorithm is not tested yet.
0x00000004: Arguments for appldr are encrypted
0x00000001: Data compressed. MetadataSection length will be 0x20 bytes.
• blockSize: The data is stored on blocks of that length. Required for decryption. Copied from EDAT offset 0x84-0x87
• numBlocks: Number of blocks on file. Calculated using: numBlocks = (fileLen + blockSize - 1)/blockSize
• blockBase: Common part of the key used on decryption. First 0xC bytes of headerHash. Copied from EDAT offset 0x60-0x6B.
• devklic: Our rif key. Copied from the entry created by syscall471. FOR SDAT it is calculated using other algorithm.
• padding: the digest from NPD. Will be the IV. Copied from EDAT offset 0x40-0x4F.
When an read request is received:
• The system determines the blocks required (E.g; read from 0x3FFF to 0x8001 will read blocks 0,1 and 2).
• For each of the blocks:
• Calculate the blockKey as blockBase concat blockNumber.
• Calculate block offset: Start of NPD + offset + 0x100 + metadataSectionLen* numBlocks + blockSize*blockNumber. metadataSectionLen is 0x10 for flag 0xC (if compressed or with special hash would be 0x20).
• Calculate erk: AESECB128Encrypt, key:rifKey, data:blockKey
• Calculate hashKey: For 0xC is erk. (Others have an additional encryption)
• Execute appLdr with the following parameters:
• Single execution
• Encrypted arguments
• CMAC. Key: hashKey, expectedHash: metadataSection[blockIndex].hash
• EncryptionCBC erk:erk, riv:npd.digest
APPLDR:
As you know the appldr is used for decrypting SELFs (that part is documented on the wiki). However there is a second mode that is used for EDAT. To use that mode spu_arg.field35 is 5. For values 0 to 4 it will process a SELF and for others will return error. Graf_chokolo described the structure of spu_args for the SELF. However this changes for EDATs…
Code:
typedef struct
{
uint64_t unk1;
uint32_t hashFlags;
uint32_t encryptionFlags;
uint64_t unk2;
uint64_t len;
uint64_t unk3;
uint64_t stateAddress;
uint32_t field30;
uint8_t field34; //Must be 0,1,2
uint8_t field35; //Must be 0,1,2,3
uint16_t field36; //Must be 0,1,2,3,4,5
uint64_t field38;
uint8_t hashKey[0x10];
uint8_t riv[0x10];
uint8_t erk[0x10];
}spu_args;
Above I indicated several parameters for the appldr. Those parameters are controlled by hashFlag and encryptionFlag.
-HashFlag: The hash is performed on input data not decrypted data. So if hash fails nothing is decrypted
MSB indicates how to use parameter hashKey.
Code:
0x10000000: Indicates that hashKey is encrypted. Decrypt it with EDATKEY and RIVKEY
0x20000000: Ignore hashKEY. USE EDATDEFAULTHASHKEY
0x00000000: hashKey is not encrypted. Use it directly
LSB indicates the type of hash.
Code:
0x00000001: HMACWithSHA1. Hash Len 0x14 bytes
0x00000002: CMAC128. Hash len 0x10 (obvious)
0x00000004: HMACWithSHA1. Hash Len 0x10 bytes (Hash is trunked)
-EncryptionFlag:
MSB indicates how to use parameters riv and erk
Code:
0x10000000: Indicated that erk is encrypted. Decrypt it with EDATKEY and RIVKEY. riv is copied
0x20000000: Ignore riv and erk. Use EDATKEY and RIVKEY
0x00000000: Use erk and riv directly
LSB indicates which encoding is used.
Code:
0x00000001: No encryption (algorithm is memcpy)
0x00000002: AESCBC128Decrypt is used.
When a key must be decrypted the algorithm is AESCBC128Decrypt. Keys SHA1:
Code:
EDATKEY: 84E9FC3574EAA11A9462FFA53D5EA46B4D0003BF. Already in wiki
RIVKEY: E129F27C5103BC5CC44BCDF0A15E160D445066FF. This is top secret :D
EDATDEFAULTHASHKEY: 8A721A06ABC7BB9BF398C5EF5D6F1FD997BC0A56
The multiple execution /single execution refers to the ability of appLdr to store an encrypted (and hashed) data on main memory to resume the hashing/decryption operations on next execution. That data is stored at stateAddress. Basically the functioning has several submodes. One for initialization (that decrypts erk, riv and hkey) and copies the state to main memory, another for processing data, which retrieves the state, process the data and updates the state, and finally another that receives the expected hash and validates. Another submode does all these ops on a single execution (calls the three submodes).
Summing up (for 0xC) for each block:
• Calculate data offset: 0x100 + offset(0) + metadataSectionLen*numberOfBlocks + currentBlockNumber*blockSize
• Generate block key: concat first 0xC byte of headerHash with current block number
• Encrypt block key with rifKey using AESECB128Encrypt. This would be erk and hkey
• Calculate riv. It is NPD digest field
• Decrypt erk using AESCBC128Decrypt with EDATKEY and RIVKEY -> call result decryptionKey.
• Using AESCBC128Decrypt decrypt data from offset to offset + blockSize (if last block calculate remaining bytes rounded up to 0x10 multiple). Key is decryptionKey iv is riv
• Copy data to output file
After searching for those missing bytes I did not found any reference on code. So I zeroed them and feed the file to the PS3... The file was properly loaded and decrypted so:
• Those bits are a random padding or
• They are not checked, nor required for creating an EDAT.
That means that you are able to "free" your EDATs using the method above. Remember that you're going to need the devklic and the rifkey.
Octopus For p3T you don't require the devklic cause for paid decryption you only need the key from rif... so decrypt it and use it directly like any other theme
EXE.trim.ALL You're right on version. LV2 uses that value to check which flags are valid. However unk4 (and unk3) which are at 0x70 are zeroes. Your info is for the next 16 bytes located at 0x80. Also you separate finalize and type. From the assembly I can say that the original source code considers it a signed integer (int32_t) (that or they have a really weird compiler cause it always load that field as a word (PPC can read a single byte)).
BTW the text on flowers says something about "werewolves" and the devklic is written as an ASCII text (not binary). It was the first non free content that I decrypted on PC.
euss IMHO best topic of the last half year was written recently by math on lan.st... half year? nah... last year. It's a pity that I would never enter on efnet (nor other sites) as long as they don't allow proxy and TOR.
Finally a bit of drama: Hotz8611, I reversed your reactPSN to see the your method and discovered that you just used the info on this post. I haven't check the vsh.self mode but I suppose that youre nullifyng the curve check and generate RAP by encrypting the rifkey (An AES and another crypto algorithm of 5 rounds with shuffle, acummulation and xoring.). I thank you for making people provide me all those RAP than I'm able to transform to rifkey but next time give proper credits (I don't know if your works is based on mallory or mine but obviously is based on info in this topic).
First of all, here is an implementation of the algorithm. It is not fully tested (for example with ISO.BIN.EDAT it validates but fails when decrypting) and is missing the decompression algorithm (I tried deflate but is does not work if someone identifies the algorithm please post it. Blocks start with 0x05). Also keys have been eliminated. On previous port you have the SHA1: http://pastebin.com/SuAukd8B
Code:
package unself;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class EDAT {
public static final int STATUS_ERROR_INPUTFILE_IO = -100;
public static final int STATUS_ERROR_HASHTITLEIDNAME = -1;
public static final int STATUS_ERROR_HASHDEVKLIC = -2;
public static final int STATUS_ERROR_MISSINGKEY = -3;
public static final int STATUS_ERROR_HEADERCHECK = -4;
public static final int STATUS_ERROR_DECRYPTING = -5;
public static final int STATUS_OK = 0;
public static final long FLAG_COMPRESSED = 0x00000001L;
public static final long FLAG_0x02 = 0x00000002L;
public static final long FLAG_KEYENCRYPTED = 0x00000008L;
public static final long FLAG_0x10 = 0x00000010L;
public static final long FLAG_0x20 = 0x00000020L;
public static final long FLAG_SDAT = 0x01000000L;
public static final long FLAG_DEBUG = 0x80000000L;
/**
*
* This function reads given file and decrypts it
*
* @param inFile EDAT file to decrypt
* @param outFile Path to store the decrypted data
* @param devKLic Authentication key. Also used for decryption on free content
* @param keyFromRif Key obtained after decrypting rif60
* @return Result of the operation
*/
public int decryptFile(String inFile, String outFile, byte[] devKLic, byte[] keyFromRif) throws FileNotFoundException, IOException {
File fin = new File(inFile);
RandomAccessFile raf = null;
raf = new RandomAccessFile(fin, "r");
NPD[] ptr = new NPD[1]; //Ptr to Ptr
int result = validateNPD(fin.getName(), devKLic, ptr, raf); //Validate NPD hashes
if (result < 0) {
return result;
}
NPD npd = ptr[0];
EDATData data = getEDATData(raf);
byte[] rifkey = getKey(npd, data, devKLic, keyFromRif); //Obtain the key for decryption (result of sc471 or sdatkey)
if (rifkey == null) {
System.out.println("ERROR: Key for decryption is missing");
return STATUS_ERROR_MISSINGKEY;
} else {
System.out.println("DECRYPTION KEY: " + ConversionUtils.getHexString(rifkey));
}
result = checkHeader(rifkey, data, raf);
if (result < 0) {
return result;
}
RandomAccessFile out = new RandomAccessFile(outFile, "rw");
result = decryptData(raf, out, npd, data, rifkey);
if (result < 0) {
return result;
}
raf.close();
return STATUS_OK;
}
private static final int HEADER_MAX_BLOCKSIZE = 0x3C00;
private int checkHeader(byte[] rifKey, EDATData data, RandomAccessFile in) throws IOException {
in.seek(0);
byte[] header = new byte[0xA0];
byte[] out = new byte[0xA0];
byte[] expectedHash = new byte[0x10];
int numBlocks = (int) ((data.getFileLen().intValue() + data.getBlockSize() - 11) / data.getBlockSize());
in.readFully(header);
in.readFully(expectedHash);
System.out.println("Checking header hash:");
AppLoader a = new AppLoader();
int hashFlag = ((data.getFlags() & FLAG_KEYENCRYPTED) == 0) ? 0x00000002 : 0x10000002;
//if ((data.getFlags() & DEBUG_FLAG) != 0) hashFlag |= 0x01000000; //Debug check not implemented
//Veryfing header
boolean result = a.doAll(hashFlag, 0x00000001, header, 0, out, 0, header.length, new byte[0x10], new byte[0x10], rifKey, expectedHash, 0);
if (!result) {
System.out.println("Error verifying header. Is rifKey valid?");
return STATUS_ERROR_HEADERCHECK;
}
System.out.println("Checking metadata hash:");
a = new AppLoader();
a.doInit(hashFlag, 0x00000001, new byte[0x10], new byte[0x10], rifKey);
int sectionSize = ((data.getFlags() & FLAG_COMPRESSED) != 0) ? 0x20 : 0x010;
int readed = 0;
int baseOffset = 0x100;
//baseOffset += modifier; //There is an unknown offset to add to the metadatasection... value seen 0
long remaining = sectionSize * numBlocks;
while (remaining > 0) {
int lenToRead = (HEADER_MAX_BLOCKSIZE > remaining) ? (int) remaining : HEADER_MAX_BLOCKSIZE;
in.seek(baseOffset + readed);
byte[] content = new byte[lenToRead];
out = new byte[lenToRead];
in.readFully(content);
a.doUpdate(content, 0, out, 0, lenToRead);
readed += lenToRead;
remaining -= lenToRead;
}
result = a.doFinal(header, 0x90);
if (!result) {
System.out.println("Error verifying metadatasection. Data tampered");
return STATUS_ERROR_HEADERCHECK;
}
return STATUS_OK;
}
private byte[] decryptMetadataSection(byte[] metadata) {
byte[] result = new byte[0x10];
result[0x00] = (byte) (metadata[0xC] ^ metadata[0x8] ^ metadata[0x10]);
result[0x01] = (byte) (metadata[0xD] ^ metadata[0x9] ^ metadata[0x11]);
result[0x02] = (byte) (metadata[0xE] ^ metadata[0xA] ^ metadata[0x12]);
result[0x03] = (byte) (metadata[0xF] ^ metadata[0xB] ^ metadata[0x13]);
result[0x04] = (byte) (metadata[0x4] ^ metadata[0x8] ^ metadata[0x14]);
result[0x05] = (byte) (metadata[0x5] ^ metadata[0x9] ^ metadata[0x15]);
result[0x06] = (byte) (metadata[0x6] ^ metadata[0xA] ^ metadata[0x16]);
result[0x07] = (byte) (metadata[0x7] ^ metadata[0xB] ^ metadata[0x17]);
result[0x08] = (byte) (metadata[0xC] ^ metadata[0x0] ^ metadata[0x18]);
result[0x09] = (byte) (metadata[0xD] ^ metadata[0x1] ^ metadata[0x19]);
result[0x0A] = (byte) (metadata[0xE] ^ metadata[0x2] ^ metadata[0x1A]);
result[0x0B] = (byte) (metadata[0xF] ^ metadata[0x3] ^ metadata[0x1B]);
result[0x0C] = (byte) (metadata[0x4] ^ metadata[0x0] ^ metadata[0x1C]);
result[0x0D] = (byte) (metadata[0x5] ^ metadata[0x1] ^ metadata[0x1D]);
result[0x0E] = (byte) (metadata[0x6] ^ metadata[0x2] ^ metadata[0x1E]);
result[0x0F] = (byte) (metadata[0x7] ^ metadata[0x3] ^ metadata[0x1F]);
return result;
}
private EDATData getEDATData(RandomAccessFile in) throws IOException {
in.seek(0x80);
byte[] data = new byte[0x10];
in.readFully(data);
return EDATData.createEDATData(data);
}
private boolean compareBytes(byte[] value1, int offset1, byte[] value2, int offset2, int len) {
boolean result = true;
for (int i = 0; i < len; i++) {
if (value1[i + offset1] != value2[i + offset2]) {
result = false;
break;
}
}
return result;
}
private int validateNPD(String filename, byte[] devKLic, NPD[] npdPtr, RandomAccessFile in) throws IOException {
in.seek(0);
byte[] npd = new byte[0x80];
in.readFully(npd);
byte[] extraData = new byte[0x04];
in.readFully(extraData);
long flag = ConversionUtils.be32(extraData, 0);
if ((flag & FLAG_SDAT) != 0) {
System.out.println("INFO: SDAT detected. NPD header is not validated");
} else if (!checkNPDHash1(filename, npd)) {
return STATUS_ERROR_HASHTITLEIDNAME;
} else if (devKLic == null) {
System.out.println("WARNING: Can not validate devklic header");
} else if (!checkNPDHash2(devKLic, npd)) {
return STATUS_ERROR_HASHDEVKLIC;
}
npdPtr[0] = NPD.createNPD(npd);;
return STATUS_OK;
}
private boolean checkNPDHash1(String filename, byte[] npd) throws UnsupportedEncodingException {
byte[] fileBytes = filename.getBytes("US-ASCII");
byte data1[] = new byte[0x30 + fileBytes.length];
System.arraycopy(npd, 0x10, data1, 0, 0x30);
System.arraycopy(fileBytes, 0x00, data1, 0x30, fileBytes.length);
byte[] hash1 = ToolsImpl.CMAC128(npdrm_omac_key3, data1, 0, data1.length);
boolean result1 = compareBytes(hash1, 0, npd, 0x50, 0x10);
if (result1) {
System.out.println("NPD hash 1 is valid (" + ConversionUtils.getHexString(hash1) + ")");
}
return result1;
}
private boolean checkNPDHash2(byte[] klicensee, byte[] npd) {
byte[] xoredKey = new byte[0x10];
ToolsImpl.XOR(xoredKey, klicensee, npdrm_omac_key2);
byte[] calculated = ToolsImpl.CMAC128(xoredKey, npd, 0, 0x60);
boolean result2 = compareBytes(calculated, 0, npd, 0x60, 0x10);
if (result2) {
System.out.println("NPD hash 2 is valid (" + ConversionUtils.getHexString(calculated) + ")");
}
return result2;
}
private byte[] getKey(NPD npd, EDATData data, byte[] devKLic, byte[] keyFromRif) {
byte[] result = null;
if ((data.getFlags() & FLAG_SDAT) != 0) {
//Case SDAT
result = new byte[0x10];
ToolsImpl.XOR(result, npd.getDevHash(), SDATKEY);
} else {
//Case EDAT
if (npd.getLicense() == 0x03) {
result = devKLic;
} else if (npd.getLicense() == 0x02) {
result = keyFromRif;
}
}
return result;
}
private int decryptData(RandomAccessFile in, RandomAccessFile out, NPD npd, EDATData data, byte[] rifkey) throws IOException {
int numBlocks = (int) ((data.getFileLen().intValue() + data.getBlockSize() - 1) / data.getBlockSize());
int metadataSectionSize = ((data.getFlags() & FLAG_COMPRESSED) != 0 || (data.getFlags() & FLAG_0x20) != 0) ? 0x20 : 0x10;
int baseOffset = 0x100; //+ offset (unknown)
for (int i = 0; i < numBlocks; i++) {
in.seek(baseOffset + i * metadataSectionSize);
byte[] expectedHash = new byte[0x10];
long offset;
int len;
int compressionEndBlock = 0;
if ((data.getFlags() & FLAG_COMPRESSED) != 0) {
byte[] metadata = new byte[0x20];
in.readFully(metadata);
byte[] result = decryptMetadataSection(metadata);
offset = ConversionUtils.be64(result, 0).intValue(); // + offset (unknown)
len = Long.valueOf(ConversionUtils.be32(result, 8)).intValue();
compressionEndBlock = Long.valueOf(ConversionUtils.be32(result, 0xC)).intValue();
System.arraycopy(metadata, 0, expectedHash, 0, 0x10);
} else {
in.readFully(expectedHash);
offset = baseOffset + i * data.getBlockSize() + numBlocks * metadataSectionSize;
len = Long.valueOf(data.getBlockSize()).intValue();
if (i == numBlocks - 1) {
len = data.getFileLen().mod(BigInteger.valueOf(data.getBlockSize())).intValue();
}
}
int realLen = len;
len = (len + 0xF) & 0xFFFFFFF0;
System.out.printf("Offset: %016X, len: %08X, realLen: %08X, endCompress: %d\r\n", offset, len, realLen,compressionEndBlock);
in.seek(offset);
byte[] encryptedData = new byte[len];
byte[] decryptedData = new byte[len];
in.readFully(encryptedData);
byte[] key = new byte[0x10];
byte[] hash = new byte[0x10];
byte[] blockKey = calculateBlockKey(i, npd.getDevHash());
ToolsImpl.aesecbEncrypt(rifkey, blockKey, 0, key, 0, blockKey.length);
if ((data.getFlags() & FLAG_0x10) != 0) {
ToolsImpl.aesecbEncrypt(rifkey, key, 0, hash, 0, key.length);
} else {
System.arraycopy(key, 0, hash, 0, key.length);
}
int cryptoFlag = ((data.getFlags() & FLAG_0x02) == 0) ? 0x2 : 0x1;
int hashFlag;
if ((data.getFlags() & FLAG_0x10) == 0) {
hashFlag = 0x02;
} else if ((data.getFlags() & FLAG_0x20) == 0) {
hashFlag = 0x04;
} else {
hashFlag = 0x01;
}
if ((data.getFlags() & FLAG_KEYENCRYPTED) != 0) {
cryptoFlag |= 0x10000000;
hashFlag |= 0x10000000;
}
if ((data.getFlags() & FLAG_DEBUG) != 0) {
cryptoFlag |= 0x01000000;
hashFlag |= 0x01000000;
}
AppLoader a = new AppLoader();
boolean result = a.doAll(hashFlag, cryptoFlag, encryptedData, 0, decryptedData, 0, encryptedData.length, key, npd.getDigest(), hash, expectedHash, 0);
if (!result) {
System.out.println("Error decrypting block " + i);
return STATUS_ERROR_DECRYPTING;
}
if ((data.getFlags() & FLAG_COMPRESSED) != 0) {
//byte[] decompress = new byte[Long.valueOf(data.getBlockSize()).intValue()];
//DECOMPRESS: MISSING ALGORITHM
//out.write(decompress, 0, data.getBlockSize());
} else {
out.write(decryptedData, 0, realLen);
}
}
return STATUS_OK;
}
private byte[] calculateBlockKey(int blk, byte[] baseKey) {
byte[] result = new byte[0x10];
System.arraycopy(baseKey, 0, result, 0, 0xC);
result[0xC] = (byte) (blk >> 24 & 0xFF);
result[0xD] = (byte) (blk >> 16 & 0xFF);
result[0xE] = (byte) (blk >> 8 & 0xFF);
result[0xF] = (byte) (blk & 0xFF);
return result;
}
class AppLoader {
private Decryptor dec;
private Hash hash;
public boolean doAll(int hashFlag, int cryptoFlag, byte[] in, int inOffset, byte[] out, int outOffset, int len, byte[] key, byte[] iv, byte[] hash, byte[] expectedHash, int hashOffset) {
doInit(hashFlag, cryptoFlag, key, iv, hash);
doUpdate(in, inOffset, out, outOffset, len);
return doFinal(expectedHash, hashOffset);
}
public void doInit(int hashFlag, int cryptoFlag, byte[] key, byte[] iv, byte[] hashKey) {
byte[] calculatedKey = new byte[key.length];
byte[] calculatedIV = new byte[iv.length];
byte[] calculatedHash = new byte[hashKey.length];
getCryptoKeys(cryptoFlag, calculatedKey, calculatedIV, key, iv);
getHashKeys(hashFlag, calculatedHash, hashKey);
setDecryptor(cryptoFlag);
setHash(hashFlag);
System.out.println("ERK: " + ConversionUtils.getHexString(calculatedKey));
System.out.println("IV: " + ConversionUtils.getHexString(calculatedIV));
System.out.println("HASH: " + ConversionUtils.getHexString(calculatedHash));
dec.doInit(calculatedKey, calculatedIV);
hash.doInit(calculatedHash);
}
public void doUpdate(byte[] in, int inOffset, byte[] out, int outOffset, int len) {
hash.doUpdate(in, inOffset, len);
dec.doUpdate(in, inOffset, out, outOffset, len);
}
public boolean doFinal(byte[] expectedhash, int hashOffset) {
return hash.doFinal(expectedhash, hashOffset);
}
private void getCryptoKeys(int cryptoFlag, byte[] calculatedKey, byte[] calculatedIV, byte[] key, byte[] iv) {
int mode = cryptoFlag & 0xF0000000;
switch (mode) {
case 0x10000000:
ToolsImpl.aescbcDecrypt(EDATKEY, EDATIV, key, 0, calculatedKey, 0, calculatedKey.length);
System.arraycopy(iv, 0, calculatedIV, 0, calculatedIV.length);
System.out.println("MODE: Encrypted ERK");
break;
case 0x20000000:
System.arraycopy(EDATKEY, 0, calculatedKey, 0, calculatedKey.length);
System.arraycopy(EDATIV, 0, calculatedIV, 0, calculatedIV.length);
System.out.println("MODE: Default ERK");
break;
case 0x00000000:
System.arraycopy(key, 0, calculatedKey, 0, calculatedKey.length);
System.arraycopy(iv, 0, calculatedIV, 0, calculatedIV.length);
System.out.println("MODE: Unencrypted ERK");
break;
default:
throw new IllegalStateException("Crypto mode is not valid: Undefined keys calculator");
}
}
private void getHashKeys(int hashFlag, byte[] calculatedHash, byte[] hash) {
int mode = hashFlag & 0xF0000000;
switch (mode) {
case 0x10000000:
ToolsImpl.aescbcDecrypt(EDATKEY, EDATIV, hash, 0, calculatedHash, 0, calculatedHash.length);
System.out.println("MODE: Encrypted HASHKEY");
break;
case 0x20000000:
System.arraycopy(EDATHASH, 0, calculatedHash, 0, calculatedHash.length);
System.out.println("MODE: Default HASHKEY");
break;
case 0x00000000:
System.arraycopy(hash, 0, calculatedHash, 0, calculatedHash.length);
System.out.println("MODE: Unencrypted HASHKEY");
break;
default:
throw new IllegalStateException("Hash mode is not valid: Undefined keys calculator");
}
}
private void setDecryptor(int cryptoFlag) {
int aux = cryptoFlag & 0xFF;
switch (aux) {
case 0x01:
dec = new NoCrypt();
System.out.println("MODE: Decryption Algorithm NONE");
break;
case 0x02:
dec = new AESCBC128Decrypt();
System.out.println("MODE: Decryption Algorithm AESCBC128");
break;
default:
throw new IllegalStateException("Crypto mode is not valid: Undefined decryptor");
}
}
private void setHash(int hashFlag) {
int aux = hashFlag & 0xFF;
switch (aux) {
case 0x01:
hash = new HMAC();
hash.setHashLen(0x14);
System.out.println("MODE: Hash HMAC Len 0x14");
break;
case 0x02:
hash = new CMAC();
hash.setHashLen(0x10);
System.out.println("MODE: Hash CMAC Len 0x10");
break;
case 0x04:
hash = new HMAC();
hash.setHashLen(0x10);
System.out.println("MODE: Hash HMAC Len 0x10");
break;
default:
throw new IllegalStateException("Hash mode is not valid: Undefined hash algorithm");
}
}
abstract class Decryptor {
public abstract void doInit(byte[] key, byte[] iv);
public abstract void doUpdate(byte[] in, int inOffset, byte[] out, int outOffset, int len);
}
class NoCrypt extends Decryptor {
@Override
public void doInit(byte[] key, byte[] iv) {
//Do nothing
}
@Override
public void doUpdate(byte[] in, int inOffset, byte[] out, int outOffset, int len) {
System.arraycopy(in, inOffset, out, outOffset, len);
}
}
class AESCBC128Decrypt extends Decryptor {
Cipher c;
@Override
public void doInit(byte[] key, byte[] iv) {
try {
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
c = Cipher.getInstance("AES/CBC/NoPadding");
AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
c.init(Cipher.DECRYPT_MODE, skeySpec, paramSpec);
} catch (InvalidKeyException ex) {
throw new IllegalStateException(ex);
} catch (InvalidAlgorithmParameterException ex) {
throw new IllegalStateException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException(ex);
} catch (NoSuchPaddingException ex) {
throw new IllegalStateException(ex);
}
}
@Override
public void doUpdate(byte[] in, int inOffset, byte[] out, int outOffset, int len) {
try {
c.update(in, inOffset, len, out, outOffset);
} catch (ShortBufferException ex) {
throw new IllegalStateException(ex);
}
}
}
abstract class Hash {
public abstract void setHashLen(int len);
public abstract void doInit(byte[] key);
public abstract void doUpdate(byte[] in, int inOffset, int len);
public abstract boolean doFinal(byte[] expectedhash, int hashOffset);
}
class HMAC extends Hash {
private int hashLen;
private Mac mac;
@Override
public void setHashLen(int len) {
if (len == 0x10 || len == 0x14) {
hashLen = len;
} else {
throw new IllegalArgumentException("Hash len must be 0x10 or 0x14");
}
}
@Override
public void doInit(byte[] key) {
try {
SecretKeySpec skeySpec = new SecretKeySpec(key, "HmacSHA1");
mac = Mac.getInstance("HmacSHA1");
mac.init(skeySpec);
} catch (InvalidKeyException ex) {
throw new IllegalStateException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException(ex);
}
}
@Override
public void doUpdate(byte[] in, int inOffset, int len) {
mac.update(in, inOffset, len);
}
@Override
public boolean doFinal(byte[] expectedhash, int hashOffset) {
byte[] result = mac.doFinal();
return compareBytes(result, 0, expectedhash, hashOffset, hashLen);
}
}
class CMAC extends Hash {
int hashLen;
byte[] key;
byte[] K1;
byte[] K2;
byte[] nonProcessed;
byte[] previous;
public CMAC() {
hashLen = 0x10;
}
@Override
public void setHashLen(int len) {
if (len == 0x10) {
hashLen = len;
} else {
throw new IllegalArgumentException("Hash len must be 0x10");
}
}
@Override
public void doInit(byte[] key) {
this.key = key;
K1 = new byte[0x10];
K2 = new byte[0x10];
calculateSubkey(key, K1, K2);
nonProcessed = null;
previous = new byte[0x10];
}
private void calculateSubkey(byte[] key, byte[] K1, byte[] K2) {
byte[] zero = new byte[0x10];
byte[] L = new byte[0x10];
ToolsImpl.aesecbEncrypt(key, zero, 0, L, 0, zero.length);
BigInteger aux = new BigInteger(1, L);
if ((L[0] & 0x80) != 0) {
//Case MSB is set
aux = aux.shiftLeft(1).xor(BigInteger.valueOf(0x87));
} else {
aux = aux.shiftLeft(1);
}
byte[] aux1 = aux.toByteArray();
if (aux1.length >= 0x10) {
System.arraycopy(aux1, aux1.length - 0x10, K1, 0, 0x10);
} else {
System.arraycopy(zero, 0, K1, 0, zero.length);
System.arraycopy(aux1, 0, K1, 0x10 - aux1.length, aux1.length);
}
aux = new BigInteger(1, K1);
if ((K1[0] & 0x80) != 0) {
aux = aux.shiftLeft(1).xor(BigInteger.valueOf(0x87));
} else {
aux = aux.shiftLeft(1);
}
aux1 = aux.toByteArray();
if (aux1.length >= 0x10) {
System.arraycopy(aux1, aux1.length - 0x10, K2, 0, 0x10);
} else {
System.arraycopy(zero, 0, K2, 0, zero.length);
System.arraycopy(aux1, 0, K2, 0x10 - aux1.length, aux1.length);
}
}
@Override
public void doUpdate(byte[] in, int inOffset, int len) {
byte[] data;
if (nonProcessed != null) {
int totalLen = len + nonProcessed.length;
data = new byte[totalLen];
System.arraycopy(nonProcessed, 0, data, 0, nonProcessed.length);
System.arraycopy(in, inOffset, data, nonProcessed.length, len);
} else {
data = new byte[len];
System.arraycopy(in, inOffset, data, 0, len);
}
int count = 0;
while (count < data.length - 0x10) {
byte[] aux = new byte[0x10];
System.arraycopy(data, count, aux, 0, aux.length);
ToolsImpl.XOR(aux, aux, previous);
ToolsImpl.aesecbEncrypt(key, aux, 0, previous, 0, aux.length);
count += 0x10;
}
nonProcessed = new byte[data.length - count];
System.arraycopy(data, count, nonProcessed, 0, nonProcessed.length);
}
@Override
public boolean doFinal(byte[] expectedhash, int hashOffset) {
byte[] aux = new byte[0x10];
System.arraycopy(nonProcessed, 0, aux, 0, nonProcessed.length);
if (nonProcessed.length == 0x10) {
ToolsImpl.XOR(aux, aux, K1);
} else {
aux[nonProcessed.length] = (byte) 0x80;
ToolsImpl.XOR(aux, aux, K2);
}
ToolsImpl.XOR(aux, aux, previous);
byte[] calculatedhash = new byte[0x10];
ToolsImpl.aesecbEncrypt(key, aux, 0, calculatedhash, 0, aux.length);
return compareBytes(expectedhash, hashOffset, calculatedhash, 0, hashLen);
}
}
}
}
About compression: Instead of having metadatasections of 0x10 byes the new section is 0x20 bytes long.
Code:
struct compressMetadataSection {
uint8_t hash[0x10];
uint64_t fileOffset;
uint32_t len;
uint32_t isEndOfCompression;
}
The obtain bytes 0x10-01F xor of data is used.
You probably forgot to decrypt the key. The result of syscall471 must be decrypted using EDATKEY and RIVKEY.
To make free files:
• Create a memory image of the file.
• Decrypt the data, so you have a memory copy of the file decrypted (for compressed no need to decompress)
• Modify NPD to make if free (0x03 instead of 0x02). Recalculate hashes using devlikc (that why we need it).
• Recrypt each block using the devklic as base to calculate blocks keys (wich will then be transformed again as does the appldr for that type).
• Once recrypted, recalculate the hashes of the sections so they matched the new value for the encrypted data.
• If compressed recalculate the offset and len on the metadatasection
• Using the new metadatasection recalculate data 0x90-0x9F.
• Using the new NPD header + new metadatasectionHash calculate hash and place it at 0xA0-0xAF.
• Write file to disk (Remember, that file is function of filename, you must overwrite (not recommend while testing) or remember to rename it properly).
The code I posted already implements SDAT. You just need the SDATKEY. The SHA1 is ED2A015EEB1BD0CE06D0447F1A22AF4C1C401E4A
However you won't find it by bruteforce as it is coded as a series of inmediate values. If you check routine sub_5529C at graf_chokolo's dump_lv2 you'll see the routine that checks the edat/sdat header. Few lines below at address 5543C you'll see those inmediate values that are xored with the hash of the NPD to create the fake rifkey (the first 0x100 bytes of the npd are loaded starting at sp + 0x110)
About compression: We don't know the algorithm but if we decrypt the data and modify the NPD so it looks like a debug you can use make_edata_npdrm to decompress it.
First of all a new revision of the algorithm: http://pastebin.com/E9ghYKj0
CHANGELOG:
• Added partial support for debug files
• Added NPD version check (between 0 and3)
• Added per version flags check
• Added support for FLAG_0x20. (Untested)
• Added support for versions 0 and 1 (ISO.BIN.EDAT). See below.
When version is 0 or 1 instead of using the digest and the hash of the NPD for calculating the block key and the apploader's IV a zeroed byte array is used as base. I hope this helps your project Snowy.
I don't think I could help Kakaroto cause most of the checks are not on current code (They probably added further checking on later firmware version) and my expertise is reading assembly which I don't have. However if I can help then in any form they only need to contact me. In fact the only think that I know that is not already public is that 0x20 bytes are copied from the appldr to main memory just before setting mailbox to 7. Those bytes are at 0x890 and probably is the hash for the whitelist.
There is no hash for SDAT. Those values are unknow and not checked (not confirmed). The only function as you have seen is to be xored to generate the key. To get the exacts values I'll need to check the SDK as those are generated there.
I haven't look for the second part of the act.dat. My hyphotesis is that the second part of the file is used when debug is enabled and is common for all the consoles (will explain the COD trick). About the digest as I said there is no checked (is a hash of the original data which is unknown until the whole file is read so it can not be used as check). Geohot zeroed it on his code, An analysis of make package will obtain then (or wait until Kakaroto has the SELF fix and hope that it included the algorithm)
About the keys:
• For the header hashes there is no change you still use rifkey to get them.
To obtain that key (get the keys from wiki. i'm using the names used there):
• Decrypt rif 0x40-0x4F with the RIF's act.dat index decryption key. Get act.dat index (last four decrypted bytes)
• Encrypt klicensee constant with your IDPS-> I'll call the result actdatkey
• Using actdatkey decrypt act.dat values from 0x10 + index*0x10 to 0x1F + index*0x10
• Using that value as key decrypt rif 0x50-0x5F
If the file is free then use the devklic directly. There are no changes for checking the headerhashes. However for the data there are two variations.
• The input keys: Previously the npd.digest was used as IV. Now it is a 0x16 bytes array of zeroes. For blockbase use 0xC zeros instead of the first 0sxc bytes of npd hash. Then append the block number. Remember to encrypt this with the rifkey.
• The apploader mode: For types 0 and 1 the keys provided to appldr are not encrypted (only compression and debug flags are allowed). They are used directly on the data
The mode for uncompressed 0x20 bytes metadata section is not tested as I do not have retail files supporting it. The only files I have with that flag on are debug... which disables hash checks (see my code). If you have one retail with that flag please send me info on it so I can adapt the code.
I'll change the flag on compression as soon as I confirm it (I have not seen that flag with value 0). The hashes on NPD element use devklic. The ones on EDAT header use rifkey(paid) or devklic(free). Check my code routines for checking NPD and EDAT header.
There is always a SELF for any EDAT (even a SELF for a SELF if NPD type is 0x20). If your version 0/1 is an EDAT for PSX or PSP you should check their emulators (located at dev_flash). In fact for PSX I can tell you that two of the 3 SELFs produce a match.
First new version for 0x3C: http://pastebin.com/TtuNF5J5
You are calculating properly the hash. However you probably are not considering FLAG0x10. This flags indicates that the algorithm for hash is HMAC instead of CMAC. If FLAG0x20 is set the hash len is 0x14, otherwise the hash is truncated to 0x10 bytes.
Also another effect of FLAG0x10 is that the hashkey != encryptionKey. When this byte is set the hashKey has to be reencrypted again to calculate the proper value. Check the code above
BTW I confirm that for files with flag0x20 the structure changes from all metadatasection + all data to metadatasection and data interleaved. That means that the metadatasectionhash is ignored. I also confirm your isEncrypted. (credits to EXE.trim.ALL)
Extract any License, DRM file Content PKG from OFW 4.11 etc from PSN by IngPereira:
Well people i have this info there because I want that more people become to be getting on this stuff there are some good contents right now on 4.11 PSN and we can extract the License files created when you purchase on OFW and the content itself PKG and i thing that this can help some people.
We can extract all drm files and because there is a exploit with the NPDRM (Edata algorithm by JuanNadie, etc) we can make FREE that files with EDATA etc so the people can use all that content, ExeTRIMall just make Fifa 12 PLAYABLE on CFW so there is some opportunity you can try to Help guys like ExeTRIMall and others if you extract content with his license now purchased on PSN from your PS3 and “maybe” that content will be PLAYABLE on CFW but the truth is that the content can be PLAYABLE on any PS3 OFW 4.11 etc if the DRM license files of that game become to be FREE.
There is Assassins creed revelations on PSN and many more content.
Well my friends in order to extract license files of content (But they will not work so quick there are more steps in order to make it PLAYABLE on CFW but this a really good step) so you can have the drm license files edat or rif) you should need you need to do this:
1. - Things you need:
• E3Flasher Dual boot or any other working FAST DUAL BOOT
• A PS3 on MA 3.56 or 3.55 CFW (NOT TESTED) and the OFW 4.11 etc.
• A Dongle that can put the PS3 on Service Mode.
• The Lv2diag.self from PRELOADER ADVANCE 2.0 by JaiCraB.
• A good knowledge about this.
Obviously you need to have your Dual boot setup ready to go.
PRELIMINARY PROCEDURE to keep using the same HDD on OFW:
We need to have the HDD like when we are on CFW again DON’T FORMAT THE HDD we just need to update on 3.55 CFW to 4.11 etc without format and keep the hdd like that on 4.11 and when we gonna down to CFW to extract content just use the good procedure by restoring a dev_flash backup with preloader advance with the Nor or nand Setup to use a CFW with the same HDD.
Well to be started you need to make the Purchase and downloading of the PKG File (obviusly take the URL of the Download).
Here the Preloader Advance 2.0: http://www.mediafire.com/?3hg7njc513w4n70 (This just works by using Service Mode)
What we should do its just keep using the same hdd of the 4.11 OFW on PSN but with a working dev_flash for the CFW 3.56 or 3.55 so the CFW can init good and we want to keep the dev_hdd0 with the folders created on 4.11 to extract all on CFW.
Like you can see is more easy to do it on the 3.56 MA because there are links working of a Backup of dev_flash to be restored with preloader advance and leave you using the same HDD (With the same dev_hdd0 of 4.11 on PSN) but now with a CFW on 3.55 you need to make a backup of dev_flash first of the CFW that you use (Kmeaw, rebug, etc) to later restore that backup when we are back to the CFW from OFW.
Later is just be on OFW and flash nor or nand on dual boot etc and put a CFW to later restore the dev_flash of that CFW on Service Mode with Preloader advance 2.0 and try to start the system to be on the XMB and copy everything.
If you try to keep using the same HDD this will work for you! If you will do this on JFW 3.56 MA you can use this backup created by good people on DemonHades.org.
http://www.mediafire.com/?ez8b4bzxexv7a0r
On CFW 3.55 I don’t know any link of backups created by preloader advance 2.0 so just make your own backup by modifying the CFG (Preloader Advance 2.0) on the line “Backup dev_flash” that is on 0 put 1 to activate the option.
When you get the URL of the PKG and the purchase become to be completed so the game or whatever is working then you can go down to use the CFW.
When your Nor or Nand is setup to use a CFW 3.56 MA or 3.55 etc (Nor or nand flashed with the right CFW) you just should be care to insert the Jig dongle in the USB Port at the right close to the BD and keep the same procedure to put the PS3 on Service Mode (You need to be sure to are on the CFW).
If you just use the dongle and you see that it worked (The PS3 should be OFF depending on the dongle) you can put the lv2diag.self and the cfg file from Preloader advance 2.0 by JaiCraB.
• The CFG file is ready to make a backup of dev_flash2 (Some drl files and account xregistry user) and restore a backup of a dev_flash in the same time.
• It restores "/dev_usb000/flash1.bin” and make "/dev_usb000/Backupflash2.bin" the PS3 should be OFF when it finished.
• If the process was OK then when you start again the PS3 you should be on the XMB and you can use a file manager or FTP to start the copying process of the HOME Folder on HDD0 and what you thing is needed maybe you can check the PKG Install created on dev_hdd0/game on OFW.
• If there is no XMB repeat the first steps about the “PRELIMINARY PROCEDURE”.
INFO:
The HDD need to be using the same encryption method (So you don’t need to format) just updating and later down to 3.55(Using dual boot with the same HDD!).
If you want to help in the investigations you can upload that content with the license purchased on some sites and other guys and me will try to do something with that, you just need to upload the license drm files of the purchase because you can grab the url of the package from the Store.
Working and extracting data from the Backups created by Preloader Advance 2.0:
You just need to use Winhex and open the dump backup on winhex and use the option from the "specialist" TAB "Interprect Image file as disk" and Winhex will show the dump now in a disk format so you can extract the data from that dump too easy by just selecting and extracting.
Thanks to DemonHades.org and JaiCraB by Preloader Advance 2.0, to exeTRIMall, JuanNadie and any more people that want to upload all his content license files.
原文结束这篇文章对想研究破解ps3授权系统的朋友们会非常有帮助!
DALAO 2012-07-17 ^.^
|
|