ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sun Feb 17, 2019 8:14 am

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jan 10, 2019 8:41 pm 

Joined: Thu Jan 10, 2019 8:38 pm
Posts: 3
Hello,
I rewrote the script for root.pfs archives.
Only tested on a single game though. Can you please add it to the compendium?

artemis-root-pfs.bms
Code:
# Generic Artemis Engine (root.pfs.*) v1.0
# Based on initial work by aluigi for Amnesia: Memories and Norn9
# script for QuickBMS https://aluigi.altervista.org/quickbms.htm or https://aluigi.zenhax.com/

# Credits to @GARbro for figuring out the XOR key calculation
# https://github.com/morkt/GARbro/blob/12bbd3a3/ArcFormats/Artemis/ArcPFS.cs#L101

QuickBMSver 0.7.3

# SHA1 hash length (160 bits)
math KEYSZ = 20

# Example for Noraneko Heart HD (NSW)
#get NAME filename
#if NAME == "root.pfs"
#    set KEY binary "\xB7\x36\x16\xDD\x3F\xE1\x0A\xF1\x22\x06\xAD\x3C\xB6\x67\x80\x72\x46\x25\x7A\x61"
#elif NAME == "root.pfs.000"
#    set KEY binary "\x83\x3D\xCB\x3D\xD8\x7D\x70\xD4\x9C\xCE\x2E\x25\xCC\xAB\x89\x43\xFB\xD0\xE3\x36"
#elif NAME == "root.pfs.001"
#    set KEY binary "\xDB\x1E\x30\x29\x7B\x8C\xC7\x58\xE1\xD7\x33\xD0\xC4\x66\x36\x87\x62\xC6\xE6\xDF"
#elif NAME == "root.pfs.002"
#    set KEY binary "\x8D\x98\xA0\x17\x31\x14\xD1\x04\xE7\x72\xFF\xC1\xA3\x60\x6E\xEC\x59\x64\x37\xC7"
#elif NAME == "root.pfs.003"
#    set KEY binary "\xD7\x98\x0D\x0E\x54\x83\x44\x90\x2C\x4C\x0D\xC9\x11\x0E\x76\x25\x94\x31\xEB\x29"
#endif

idstring "pf"
getdstring VER 1    # '6', '8' and so on
if VER == "8"
    codepage 932
endif

get INFO_SIZE long
SavePos INFO_OFFSET
Log MEMORY_FILE INFO_OFFSET INFO_SIZE
Encryption sha1 MEMORY_FILE
Log MEMORY_FILE 0 0
print "KEY %QUICKBMS_HEXHASH%"
GoTo INFO_OFFSET
get FILES long
for i = 0 < FILES
    get NAMESZ long
    getdstring NAME NAMESZ
    get ZERO long
    get OFFSET long
    get SIZE long

    set EXT extension NAME
    if EXT == "mp4"
    else
        encryption xor QUICKBMS_HASH 0 KEYSZ
    endif
    log NAME OFFSET SIZE
    encryption "" ""
next i


Top
   
PostPosted: Thu Jan 10, 2019 9:05 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9767
:D


Top
   
PostPosted: Sat Feb 09, 2019 11:31 am 

Joined: Thu Jan 10, 2019 8:38 pm
Posts: 3
root.pfs archives with a pf6 idstring (cleartext, apparently) were not handled properly.

Here's a v2.

Code:
# Generic Artemis Engine (root.pfs.*)
# Based on initial work by aluigi for Amnesia: Memories and Norn9
# v2 handles 'pf6' as cleartext
# script for QuickBMS http://quickbms.aluigi.org

# Credits to @GARbro for figuring out the XOR key calculation
# https://github.com/morkt/GARbro/blob/12bbd3a3/ArcFormats/Artemis/ArcPFS.cs#L101

# SHA1 hash length (160 bits)
math KEYSZ = 20

get NAME filename
# Example for Noraneko Heart HD (NSW)
#if NAME == "root.pfs"
#    set KEY binary "\xB7\x36\x16\xDD\x3F\xE1\x0A\xF1\x22\x06\xAD\x3C\xB6\x67\x80\x72\x46\x25\x7A\x61"
#elif NAME == "root.pfs.000"
#    set KEY binary "\x83\x3D\xCB\x3D\xD8\x7D\x70\xD4\x9C\xCE\x2E\x25\xCC\xAB\x89\x43\xFB\xD0\xE3\x36"
#elif NAME == "root.pfs.001"
#    set KEY binary "\xDB\x1E\x30\x29\x7B\x8C\xC7\x58\xE1\xD7\x33\xD0\xC4\x66\x36\x87\x62\xC6\xE6\xDF"
#elif NAME == "root.pfs.002"
#    set KEY binary "\x8D\x98\xA0\x17\x31\x14\xD1\x04\xE7\x72\xFF\xC1\xA3\x60\x6E\xEC\x59\x64\x37\xC7"
#elif NAME == "root.pfs.003"
#    set KEY binary "\xD7\x98\x0D\x0E\x54\x83\x44\x90\x2C\x4C\x0D\xC9\x11\x0E\x76\x25\x94\x31\xEB\x29"
#endif

idstring "pf"
getdstring VER 1    # '6', '8' and so on
codepage 932
# If you see weird filenames, you may also want to try UTF-8 (e.g. for console or phone games):
# codepage 65001

get INFO_SIZE long
SavePos INFO_OFFSET
if VER == "8"
    Log MEMORY_FILE INFO_OFFSET INFO_SIZE
    Encryption sha1 MEMORY_FILE
    Set KEY binary QUICKBMS_HASH
elif VER == "6"
    set KEY binary "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
endif

# cannot get this dump to work:
#print "KEY %KEY|dump20%"

GoTo INFO_OFFSET
get FILES long
for i = 0 < FILES
    get NAMESZ long
    getdstring NAME NAMESZ
    get ZERO long
    get OFFSET long
    get SIZE long

    set EXT extension NAME
    if EXT == "mp4"
    else
        encryption xor KEY 0 KEYSZ
    endif
    log NAME OFFSET SIZE
    encryption "" ""
next i
Log MEMORY_FILE 0 0


Attachments:
File comment: Download script
artemis-root-pfs-v2.bms [1.95 KiB]
Downloaded 8 times
Top
   
PostPosted: Sat Feb 09, 2019 12:31 pm 

Joined: Thu Jan 10, 2019 8:38 pm
Posts: 3
Sorry for spamming. Here is v3 handling pf2 archives and quitting if version is not handled (pf2, pf6 or pf8)

Code:
# Generic Artemis Engine (root.pfs.*)
# Based on initial work by aluigi for Amnesia: Memories and Norn9
# v3 handles 'pf2' as cleartext, quits if magic is not handled
# v2 handles 'pf6' as cleartext
# script for QuickBMS http://quickbms.aluigi.org

# Credits to @GARbro for figuring out the XOR key calculation
# https://github.com/morkt/GARbro/blob/12bbd3a3/ArcFormats/Artemis/ArcPFS.cs#L101

# SHA1 hash length (160 bits)
math KEYSZ = 20

get NAME filename
# Example for Noraneko Heart HD (NSW)
#if NAME == "root.pfs"
#    set KEY binary "\xB7\x36\x16\xDD\x3F\xE1\x0A\xF1\x22\x06\xAD\x3C\xB6\x67\x80\x72\x46\x25\x7A\x61"
#elif NAME == "root.pfs.000"
#    set KEY binary "\x83\x3D\xCB\x3D\xD8\x7D\x70\xD4\x9C\xCE\x2E\x25\xCC\xAB\x89\x43\xFB\xD0\xE3\x36"
#elif NAME == "root.pfs.001"
#    set KEY binary "\xDB\x1E\x30\x29\x7B\x8C\xC7\x58\xE1\xD7\x33\xD0\xC4\x66\x36\x87\x62\xC6\xE6\xDF"
#elif NAME == "root.pfs.002"
#    set KEY binary "\x8D\x98\xA0\x17\x31\x14\xD1\x04\xE7\x72\xFF\xC1\xA3\x60\x6E\xEC\x59\x64\x37\xC7"
#elif NAME == "root.pfs.003"
#    set KEY binary "\xD7\x98\x0D\x0E\x54\x83\x44\x90\x2C\x4C\x0D\xC9\x11\x0E\x76\x25\x94\x31\xEB\x29"
#endif

idstring "pf"
getdstring VER 1    # '6', '8' and so on
codepage 932
# If you see weird filenames, you may also want to try UTF-8 (e.g. for console or phone games):
# codepage 65001

get INFO_SIZE long
SavePos INFO_OFFSET
if VER == "8"
    Log MEMORY_FILE INFO_OFFSET INFO_SIZE
    Encryption sha1 MEMORY_FILE
    Set KEY binary QUICKBMS_HASH
elif VER == "6"
    set KEY binary "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
elif VER == "2"
    print "hello"
    Math INFO_OFFSET + 4
    set KEY binary "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
else
    print "ERROR This version is not supported: %VER%"
   cleanexit
endif

# cannot get this dump to work:
#print "KEY %KEY|dump20%"

GoTo INFO_OFFSET
get FILES long
for i = 0 < FILES
    get NAMESZ long
    getdstring NAME NAMESZ
    if VER == "2"
       get SIZEOFCRAP long
      Math SIZEOFCRAP - 8
      GoTo SIZEOFCRAP 0 SEEK_CUR
    else
        get ZERO long
    endif
    get OFFSET long
    get SIZE long

    set EXT extension NAME
    if EXT == "mp4"
    else
        encryption xor KEY 0 KEYSZ
    endif
    log NAME OFFSET SIZE
    encryption "" ""
next i
Log MEMORY_FILE 0 0


Attachments:
File comment: Version 3
artemis-root-pfs-v3.bms [2.35 KiB]
Downloaded 7 times
Top
   
PostPosted: Sat Feb 09, 2019 3:47 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9767
Cool, do you know if exist other versions to cover?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited