Editing PARAM.PFD
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
[[Category:Software]] | |||
[[ | |||
==Description== | ==Description== | ||
'''PFD''' ('''P'''rotected '''F'''iles '''D'''atabase) are responsible to prevent tampering of other files of the same folder, the only purpose is the security of the folder contents. Contains the cryptographic signatures of other files of the same folder (not all, but the ones that developers decided to be important enought to be secured). | '''PFD''' ('''P'''rotected '''F'''iles '''D'''atabase) are responsible to prevent tampering of other files of the same folder, the only purpose is the security of the folder contents. Contains the cryptographic signatures of other files of the same folder (not all, but the ones that developers decided to be important enought to be secured). | ||
Its used in several paths of the PS3, usually to secure data related with the user profile e.g: | Its used in several paths of the PS3, usually to secure data related with the user profile e.g: | ||
/dev_hdd0/home/0000000*/savedata/SAVEDATA_DIRECTORY/PARAM.PFD <---- in all save game folders | /dev_hdd0/home/0000000*/savedata/SAVEDATA_DIRECTORY/PARAM.PFD <---- in all save game folders | ||
/dev_hdd0/home/0000000*/trophy/NPCOMMID/PARAM.PFD <--- in all | /dev_hdd0/home/0000000*/trophy/NPCOMMID/PARAM.PFD <--- in all trohpy folders | ||
/dev_hdd0/home/0000000*/trophy/_TROPSYS_/PARAM.PFD <---- in the "user trophy index" folder | /dev_hdd0/home/0000000*/trophy/_TROPSYS_/PARAM.PFD <---- in the "user trophy index" folder | ||
Line 35: | Line 31: | ||
Total file size = 96+24+456+31008+1140+44 = 32768 bytes (0x8000) | Total file size = 96+24+456+31008+1140+44 = 32768 bytes (0x8000) | ||
The size of the file is fixed because the number of entries in both '''X table''' & '''Y table''' is 57 (when the entry is not used his position is marked as "not-used"). In the same way... the '''Protected files table''' has an area reserved for a maximun of 114 entries (not used entries are filled with zeroes). As result the file contains the maximun number of possible entries | |||
The size of the file is fixed because the number of entries in both '''X table''' & '''Y table''' is 57 (when the entry is not used | |||
*Useful game saves used in this page as examples | *Useful game saves used in this page as examples | ||
**http://www.gamefaqs.com/ps3/941950-mirrors-edge/saves ( | **http://www.gamefaqs.com/ps3/941950-mirrors-edge/saves (the first one region North America). Mirror: http://www.multiupload.nl/SWJ4Y4H7ER | ||
**http://www.gamefaqs.com/ps3/933123-heavy-rain/saves | **http://www.gamefaqs.com/ps3/933123-heavy-rain/saves | ||
The structure of the PARAM.PFD used in Mirror's edge game save can be considered "rare", this wiki page uses this file for explaining the structure because is perfect to understand how it works, the structure contains all the "problems" not present in "standard" files that can be considered unknown... there are other game saves that can be used (MotoGP10, Heavy rain)... but the list of protected files in heavy rain contains more than 100 files (use heavy rain if you are coding an app as a "stress test") | The structure of the PARAM.PFD used in Mirror's edge game save can be considered "rare", this wiki page uses this file for explaining the structure because is perfect to understand how it works, the structure contains all the "problems" not present in "standard" files that can be considered unknown... there are other game saves that can be used (MotoGP10, Heavy rain)... but the list of protected files in heavy rain contains more than 100 files (use heavy rain if you are coding an app as a "stress test") | ||
Line 126: | Line 65: | ||
| rowspan="4" style="background-color:#DDDDDD;" | '''header <br /> table''' || 0x20 || 0x14 (20 bytes) || 7C1F5C28A7EE4D3922ADC828E6CD7888980F33B6 || '''Y-Table SHA1-HMAC hash''' || Used only occupied space, i.e. without padding | | rowspan="4" style="background-color:#DDDDDD;" | '''header <br /> table''' || 0x20 || 0x14 (20 bytes) || 7C1F5C28A7EE4D3922ADC828E6CD7888980F33B6 || '''Y-Table SHA1-HMAC hash''' || Used only occupied space, i.e. without padding | ||
|- | |- | ||
| 0x34 || 0x14 (20 bytes) || 2394EEE99706774E71912413A7CFDBE5E38E8D0C || ''' | | 0x34 || 0x14 (20 bytes) || 2394EEE99706774E71912413A7CFDBE5E38E8D0C || '''X-Table SHA1-HMAC hash''' || Data started at 0x60 | ||
|- | |- | ||
| 0x48 || 0x14 (20 bytes)|| 5BCF880FCB7B59C4C5A3D983904B6CEEDE27152 || '''file_hmac_key''' || | | 0x48 || 0x14 (20 bytes)|| 5BCF880FCB7B59C4C5A3D983904B6CEEDE27152 || '''file_hmac_key''' || | ||
Line 175: | Line 114: | ||
From 0x78 to 0x240 | From 0x78 to 0x240 | ||
Size = 456 bytes | Size = 456 bytes | ||
Entry | Entry lenght = 8 bytes | ||
Number of entries = 57 | Number of entries = 57 | ||
Each entry can contain a "file index" (from 0x00 to 0x71... or 1 to 114 in decimal) that is pointing (or is | Each entry can contain a "file index" (from 0x00 to 0x71... or 1 to 114 in decimal) that is pointing (or is asigned) to one of the files in the '''Protected files table'''. How this assignation works is unknown | ||
If the "file index" is 72 (position 115) it means that is pointing out of the '''Protected files table''' (not used) | If the "file index" is 72 (position 115) it means that is pointing out of the '''Protected files table''' (not used) | ||
Line 186: | Line 125: | ||
The table does not fills with entries from top to bottom, usually the first entries are not used (marked as 72) followed by entries with whatever number from 0 to 71 (by now the entries used seems random), and mixed with more 72's entries | The table does not fills with entries from top to bottom, usually the first entries are not used (marked as 72) followed by entries with whatever number from 0 to 71 (by now the entries used seems random), and mixed with more 72's entries | ||
Used entries has a number | Used entries has a number asigned by his position in the table e.g: | ||
*Mirror's edge game save '''X table''' | *Mirror's edge game save '''X table''' | ||
Line 359: | Line 298: | ||
From 0x240 to 0x7B60 | From 0x240 to 0x7B60 | ||
Size = 31008 bytes | Size = 31008 bytes | ||
Entry | Entry lenght = 272 bytes | ||
Number of reserved entries = 114 | Number of reserved entries = 114 | ||
Number of used entries = variable from 1 to 114 | Number of used entries = variable from 1 to 114 | ||
Line 377: | Line 316: | ||
|} | |} | ||
* | *Note | ||
Certificate: | Certificate: When the file is PARAM.SFO the certificate is longer and maybe uses imput data from "PARAMS" and/or "ACCOUNT_ID" inside PARAM.SFO. Method unknown (Null-terminated) | ||
Each entry can store the signature of one of the files in the folder, there is always an entry used to store the signature of [[PARAM.SFO]], this gives a | Each entry can store the signature of one of the files in the folder, there is always an entry used to store the signature of [[PARAM.SFO]], this gives a maximun number of protected files generated by the game of 113. Used entries fills the table from top to bottom, not-used entries are placed at the end of the table filled with zeroes | ||
The first 8 bytes of each entry (Virtual Index ID) works in the same way than the entries in the '''X table''', when not used are marked as "72" and when used are | The first 8 bytes of each entry (Virtual Index ID) works in the same way than the entries in the '''X table''', when not used are marked as "72" and when used are randomnly placed asigning a "file index" to the entry. This "file index" does not matches with the position of the entry in the '''Protected files table''' itself... (e.g: indexed 0x06 is in position 14) | ||
For a | For a theoricall file with alll entries used (114 protected files), half of the "file index" numbers will be spreaded between the '''X table''' (can only contain 57) ant the first 8 bytes of some entries in the '''Protected files table''' (the other 57) | ||
*Mirror's edge game save '''Protected Files Table''' | *Mirror's edge game save '''Protected Files Table''' | ||
Line 467: | Line 404: | ||
From 0x7B60 to 0x7FD4 | From 0x7B60 to 0x7FD4 | ||
Size = 1140 bytes | Size = 1140 bytes | ||
Entry | Entry lenght = 20 bytes (SHA-1 HMAC digest) | ||
Number of entries = 57 | Number of entries = 57 | ||
Is directly related with the '''X table''', both matches in the total number of entries (57) and | Is directly related with the '''X table''', both matches in the total number of entries (57) and wich ones are used (e.g. when the '''X table''' has a entry in position 12... the '''Y table''' has position 12 used) | ||
Only used entries contains a real SHA1-HMAC hash. It can be the SHA1-HMAC hash of entry (a concatenation of 0x41 bytes of '''File Name''' and 0xC0 bytes of '''File certificate''' is used as data) or some unknown SHA1-HMAC hash (hash of file data related to the entry?). Unused entries have a "default" hash (SHA1-HMAC of empty data). In a | Only used entries contains a real SHA1-HMAC hash. It can be the SHA1-HMAC hash of entry (a concatenation of 0x41 bytes of '''File Name''' and 0xC0 bytes of '''File certificate''' is used as data) or some unknown SHA1-HMAC hash (hash of file data related to the entry?). Unused entries have a "default" hash (SHA1-HMAC of empty data). In a theoricall PARAM.PFD with no files listed, the '''Y table''' would have all his 57 entries with a default hash). | ||
The '''Y table''' has a repeating pattern so an entry for each potential file with the blank entry (I.E. no file) being represented by the repeating byte pattern. | The '''Y table''' has a repeating pattern so an entry for each potential file with the blank entry (I.E. no file) being represented by the repeating byte pattern. | ||
Line 614: | Line 551: | ||
===How to blank the tables=== | ===How to blank the tables=== | ||
In the header of the file there are 3 hashes that belongs to the 3 tables (X table, protected files table, and Y table). The first step needed to modify the file is to be able to generate this hashes for our "new" | In the header of the file there are 3 hashes that belongs to the 3 tables (X table, protected files table, and Y table). The first step needed to modify the file is to be able to generate this hashes for our "new" modifyed tables... but in fact, this hashes are the "only" thing needed to pwn the whole file security, because we can "clean-up" all the tables (in other words, we dont need to understand how this tables are built, how the protected files signatures are generated, or what this ID's means, because we can erase all this data): | ||
*1.- First is needed to look at "X table" to find an entry marked as 0x72 (not used), then go to the "Y table" and using this same position make a copy of the entry (this will be needed later in step 5 when cleaning-up "Y table" by pasting this value repeatedly) | *1.- First is needed to look at "X table" to find an entry marked as 0x72 (not used), then go to the "Y table" and using this same position make a copy of the entry (this will be needed later in step 5 when cleaning-up "Y table" by pasting this value repeatedly) | ||
*2.- Fill with zeroes the value "Protected files table used entries" (from 0x70 to 0x78) | *2.- Fill with zeroes the value "Protected files table used entries" (from 0x70 to 0x78) | ||
*3.- Fill "X table" with "not-used" | *3.- Fill "X table" with "not-used" entryes (from 0x78 to 0x240... paste 57 times the entry 0000000000000072) | ||
*4.- Fill with zeroes all the "protected files table" (from 0x240 to 0x7B60) | *4.- Fill with zeroes all the "protected files table" (from 0x240 to 0x7B60) | ||
*5.- Fill "Y table" with "not-used" entries (from 0x7B60 to 0x7FD4... paste 57 times the "not used" value for this table copyed previously) | *5.- Fill "Y table" with "not-used" entries (from 0x7B60 to 0x7FD4... paste 57 times the "not used" value for this table copyed previously) | ||
After cleaning-up the tables and regenerating | After cleaning-up the tables and regenerating his hashes, the behaviour of the PS3 when trying to load this "BLANKED.PFD" file can give some possible results: | ||
*File is valid, is loaded, but there is "something" that states this file originally had X "protected files" listed.... but now there is none = epic fail | *File is valid, is loaded, but there is "something" that states this file originally had X "protected files" listed.... but now there is none = epic fail | ||
*File is valid, is loaded, and PARAM.SFO is added to the list of protected files (this is something that seems to happen "by default"), consequently the PARAM.PFD is updated, both files are valid = partial win | *File is valid, is loaded, and PARAM.SFO is added to the list of protected files (this is something that seems to happen "by default"), consequently the PARAM.PFD is updated, both files are valid = partial win | ||
*File is valid, is loaded, no protected files are added to the list = epic win | *File is valid, is loaded, no protected files are added to the list = epic win | ||
It depends of the function that creates/updates the .PFD | It depends of the function that creates/updates the .PFD wich files needs to be added to the list of "protected files" (this is done the first time when the file is created), but probably games can add more files for his game saves | ||
The theory is simple... is a valid file with empty tables, | The theory is simple... is a valid file with empty tables, is something not tested yet, but if somebody finds a way to generate the header hashes... this theory is the next test that worths a try | ||
===The "virtual index"=== | ===The "virtual index"=== | ||
Mirror's edge has a total of 33 "protected files" (listed in the protected files table)... this number matches with the 33 "indexed" numbers that are spreading between "X table" and "protected files table" itself... if we place all the entries from all tables together we can reorder all by using | Mirror's edge has a total of 33 "protected files" (listed in the protected files table)... this number matches with the 33 "indexed" numbers that are spreading between "X table" and "protected files table" itself... if we place all the entries from all tables together we can reorder all by using his ID number in a "virtual index" | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 713: | Line 650: | ||
===More brainstorming=== | ===More brainstorming=== | ||
*The | *The maximun number of entries in the '''Protected files table''' (114) is exactly the double than the maximun number of entries in '''X table''' (57) & '''Y table''' (57). Or from other point of view 114 = 57 + 57 | ||
**Seems obvious that there is an "index number" assigned to each "protected file", but | **Seems obvious that there is an "index number" assigned to each "protected file", but his positions are "scrambled" | ||
*The order of the files in the "protected files table" is based | *The order of the files in the "protected files table" is based in his timestamps (not alphabetically, not by size). Or in other words... is related with how the PARAM.PFD was generated for first time | ||
** | **Is the original order when the file was created for first time (based in his timestamps), when the files in the list are updated by the ps3 (his timestamp changes) they keeps his original position. When new files are added to the "protected files list table"... are added to the end of the list, based in his timestamps. | ||
**When several "protected files" | **When several "protected files" has the same timestamp (something very probable because can be generated by the game very fast)... the order is alphabeticall | ||
**So when ordering them, the timestamp is preferent... and when | **So when ordering them, the timestamp is preferent... and when timestamp matches is used his name (alphabetically) | ||
*Indexed files in the '''X table''' has a different number for each one, never repeats, but there is not direct relationship between the number of entries in '''X table''' & '''Y table''' (both are fixed to 57) and the | *Indexed files in the '''X table''' has a different number for each one, never repeats, but there is not direct relationship between the number of entries in '''X table''' & '''Y table''' (both are fixed to 57) and the numer of files listed in the '''Protected files table''' (114)... the most logicall explain if that this 114 "protected files" can be linked to both tables (57 each)... but in fact the only table that stores crypto is the '''Y table''' (limited to 57)... so what trick they used ? hmmmm | ||
*What are this index in the '''X table''' and in the '''Protected files table''' itself?, | *What are this index in the '''X table''' and in the '''Protected files table''' itself?, his positions seems to be random (but the number of indexed files matches with the number of "protected files"), seems like an old school "lucas arts games" anticheat card where you pick 2 values and by mixing them you get the unlock code :D | ||
**Seems to be "jumps" from one table to the other. The files are | **Seems to be "jumps" from one table to the other. The files are readed in order by the ps3 by "jumping" using his "index nº" to locate the next one... "Index nº0" seems to be located always at position 8 in the "X-Table" (offset 0xB8). In most complex PARAM.SFO (e.g: heavy rain, mirror's edge or motogp10/11) the value at this position is replaced by another "index nº" (by now seems random) that is pointing to the "protected files table" index area of each entry (where index nº0 is located). How this "jumps" works is partially unknown and by now is only notable in the first jump | ||
Line 733: | Line 670: | ||
Discussion thread ---> http://www.ps3hax.net/showthread.php?p=392684#post392684 | Discussion thread ---> http://www.ps3hax.net/showthread.php?p=392684#post392684 | ||