[RELEASE] MRS File Specs

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Programming Addict Lambda is offline
    MemberRank
    Sep 2007 Join Date
    SpainLocation
    393Posts

    [RELEASE] MRS File Specs

    I'm are releasing that because i think is usefull to understand the MRS File format, im now trying to crypt MRS files.

    MRS File Specification by CBWhiz.
    File version 1.0 - 11/12/05

    This file spec / implementation design was helped greatly by the ZIP file format spec, located at PKWARE, Inc. - Developer’s Tools. It is assumed you read it.


    When Gunz starts, it enumerates, starting at its local folder, all files.
    Each file (unless it starts with mrs or zip, or is a folder) is treated exactly the same, wrapped in an MZFile class, and stored inside the MZFilesystem.
    If it is a folder, it calls itself again to enumerate /that/ folder.
    If it is a MRS / ZIP, it treats these as file system extentions. This means MZip::Initalize is called, and that adds each file inside to the MZFilesystem itself.
    To access a file, Gunz talks to the MZFileSystem and asks for a file.
    This subroutine checks the file list, sees if it is a MZFile or if it is stored in an MZip. If it is in a MZip, it calls MZip::Readfile and returns it, otherwise it just returns the file normally.

    This has the following benifits:
    -Gunz code doesnt care where the file comes from
    -MAIET can easily debug by simply removeing (say) system.mrs and creating a folder called system.




    How Gunz Reads MRS files:

    MZip::Initalize(mrsfile, 4); //Called to set it up
    MZip::ReadFile(filename, length);


    --------------------------------------------------------------------------------------------

    MZip::ReadFile(char* filename, int length) {
    /*
    lookup file in central directory
    (not shown)
    */
    SEEK to local file header for file
    READ local file header beginning (1E bytes, doesnt include filename, etc)
    DECRYPT lfh:
    LEA ECX,DWORD PTR SS:[(lfh)]
    MOV EDI,1E
    L002:
    MOV AL,BYTE PTR DS:[ECX]
    MOV DL,AL
    SHR DL,3
    SHL AL,5
    OR DL,AL
    NOT DL
    MOV BYTE PTR DS:[ECX],DL
    INC ECX
    DEC EDI
    JNZ L002 //(same scheme as always)
    CHECK lfh magic number:
    CMP EAX, 4034B50 //ZIP lfh magic number - seems like all v2 MRS files have this also
    CMP EAX,85840000 //Theoreticly MRS version 1 magic number, but I have no edvidance. I think MAIET just got lazy.
    ADD filename length and extra feild length
    CHECK if the file is uncompressed.
    If so, READ it and return it.
    CHECK compression method. If it is not deflate, it returns. (MZip can only handle delfate)
    READ file
    Credits to CBWhiz


  2. #2
    Account Upgraded | Title Enabled! kochon is offline
    MemberRank
    Nov 2006 Join Date
    MontrealLocation
    1,451Posts

    Re: [RELEASE] MRS File Specs

    thanks, was a pleasant reading

  3. #3
    Account Upgraded | Title Enabled! RepublicOfAstra is offline
    MemberRank
    Dec 2006 Join Date
    1,122Posts

    Re: [RELEASE] MRS File Specs

    You skipped a shitload of the post.

    [quote]MRS File Specification by CBWhiz.
    File version 1.0 - 11/12/05

    This file spec / implementation design was helped greatly by the ZIP file format spec, located at PKWARE, Inc. - Developer’s Tools. It is assumed you read it.


    When Gunz starts, it enumerates, starting at its local folder, all files.
    Each file (unless it starts with mrs or zip, or is a folder) is treated exactly the same, wrapped in an MZFile class, and stored inside the MZFilesystem.
    If it is a folder, it calls itself again to enumerate /that/ folder.
    If it is a MRS / ZIP, it treats these as file system extentions. This means MZip::Initalize is called, and that adds each file inside to the MZFilesystem itself.
    To access a file, Gunz talks to the MZFileSystem and asks for a file.
    This subroutine checks the file list, sees if it is a MZFile or if it is stored in an MZip. If it is in a MZip, it calls MZip::Readfile and returns it, otherwise it just returns the file normally.

    This has the following benifits:
    -Gunz code doesnt care where the file comes from
    -MAIET can easily debug by simply removeing (say) system.mrs and creating a folder called system.




    How Gunz Reads MRS files:

    MZip::Initalize(mrsfile, 4); //Called to set it up
    MZip::ReadFile(filename, length);


    --------------------------------------------------------------------------------------------

    MZip::ReadFile(char* filename, int length) {
    /*
    lookup file in central directory
    (not shown)
    */
    SEEK to local file header for file
    READ local file header beginning (1E bytes, doesnt include filename, etc)
    DECRYPT lfh:
    LEA ECX,DWORD PTR SS:[(lfh)]
    MOV EDI,1E
    L002:
    MOV AL,BYTE PTR DS:[ECX]
    MOV DL,AL
    SHR DL,3
    SHL AL,5
    OR DL,AL
    NOT DL
    MOV BYTE PTR DS:[ECX],DL
    INC ECX
    DEC EDI
    JNZ L002 //(same scheme as always)
    CHECK lfh magic number:
    CMP EAX, 4034B50 //ZIP lfh magic number - seems like all v2 MRS files have this also
    CMP EAX,85840000 //Theoreticly MRS version 1 magic number, but I have no edvidance. I think MAIET just got lazy.
    ADD filename length and extra feild length
    CHECK if the file is uncompressed.
    If so, READ it and return it.
    CHECK compression method. If it is not deflate, it returns. (MZip can only handle delfate)
    READ file
    }




    MZip::Initialize(FILE* mrsfile, LOADTYPE loadwhichtypes) {
    note: loadwhichtypes seems to be a global variable, not a function param

    READ offset 0x0 as a 4 byte DWORD
    Compare the first four bytes:
    50 4B 03 04 ( ASCII: PK.. ) = ZIP file
    00 00 84 85 ( ASCII: ..

  4. #4
    Account Upgraded | Title Enabled! xHalloweenX is offline
    MemberRank
    Sep 2007 Join Date
    Jonesboro, ArkaLocation
    218Posts

    Re: [RELEASE] MRS File Specs

    wow lol that was intresting

  5. #5
    Account Upgraded | Title Enabled! Hymn is offline
    MemberRank
    Jan 2007 Join Date
    269Posts

    Re: [RELEASE] MRS File Specs

    So if I were to put in a custom .mrs file, as long as it has the correct listing (like for instance, update2.mrs updates a few model files) filewise, it opens and treats those files as normal, regardless?

    This is interesting...

  6. #6
    Reverse Engineer ThievingSix is offline
    MemberRank
    Mar 2007 Join Date
    CaliforniaLocation
    901Posts

    Re: [RELEASE] MRS File Specs

    Should I just post my mrs class as a useable dll?

  7. #7
    This is bullshit. alextepes is offline
    MemberRank
    Sep 2006 Join Date
    CanadaLocation
    310Posts

    Re: [RELEASE] MRS File Specs

    Its the same as a GRF file pretty much lol, in a sense where it sees directories in gayassfilewethoughtwecouldtrickyouwith.lol

  8. #8
    Reverse Engineer ThievingSix is offline
    MemberRank
    Mar 2007 Join Date
    CaliforniaLocation
    901Posts

    Re: [RELEASE] MRS File Specs

    No, it's a ZIP file with encryption on the file headers. Without the file header encryption you can rename it to .zip and extract.

  9. #9
    Alpha Member WGFreak is offline
    MemberRank
    Jun 2007 Join Date
    Planet Earth.Location
    1,469Posts

    Re: [RELEASE] MRS File Specs

    So, i can reverse MZip routine in the client and make my own encryption?

  10. #10
    Reverse Engineer ThievingSix is offline
    MemberRank
    Mar 2007 Join Date
    CaliforniaLocation
    901Posts

    Re: [RELEASE] MRS File Specs

    Quote Originally Posted by WGFreak View Post
    So, i can reverse MZip routine in the client and make my own encryption?
    You can sure try =)

  11. #11
    Alpha Member WGFreak is offline
    MemberRank
    Jun 2007 Join Date
    Planet Earth.Location
    1,469Posts

    Re: [RELEASE] MRS File Specs

    @thiev: May you tell me how your custom encryption works?

  12. #12
    Reverse Engineer ThievingSix is offline
    MemberRank
    Mar 2007 Join Date
    CaliforniaLocation
    901Posts

    Re: [RELEASE] MRS File Specs

    It's not nessecarily reversing the MZip routine, it can be as simple as editing it. Basically easy byte goes into the encryption algorithm and gets changed by xors, nots, ors, shls, shrs, sub, add, IMUL, IDIV, etc. It's understanding all that and the knowledge to apply it is the key.

  13. #13
    Extreme Coder - Delphi bounty-hunter is offline
    MemberRank
    Sep 2007 Join Date
    GunZone MansionLocation
    1,725Posts

    Re: [RELEASE] MRS File Specs

    ....... i get this feeling ThievingSix is gona code something .......

  14. #14
    Reverse Engineer ThievingSix is offline
    MemberRank
    Mar 2007 Join Date
    CaliforniaLocation
    901Posts

    Re: [RELEASE] MRS File Specs

    Quote Originally Posted by bounty-hunter View Post
    ....... i get this feeling ThievingSix is gona code something .......
    I will as soon as a finish with my kernel driver and TCP encapsulation for LG's new antihack. I've been real busy lately and haven't found enough time in the day todo everything I need. I've started work on a .dll that works with the MRS file class and can be used by anyone. I just haven't had the time.

    ...and that being said, its 12:30 am..again...shit...

  15. #15
    Programming Addict Lambda is offline
    MemberRank
    Sep 2007 Join Date
    SpainLocation
    393Posts

    Re: [RELEASE] MRS File Specs

    im now trying to change the encryption of the header



Page 1 of 2 12 LastLast

Advertisement