[Small Release] (VSRO) Skilldataenc (de)cryption

02/06/2012 08:47 ~Nicole#1
Released on RZ a week ago, giving it a shot at epvp aswell. Hope some people find this useful.

Credits to Schickl aswell in helping :handsdown:

Original RZ Post:

Quote:
Hey guys, today I'm releasing my first tool here in the Release section, dont be too hard with me ;)

The tool basically is the same as the SRODecrypt, but with a nice little new addition: it lets you add custom stuff and you don't need to play around with hex Editors anymore! :wink:

What you need: The Download below
  • The Folder HAS to be on a NTFS Drive (Can be any USB drive formatted in the NTFS-System)
  • The Folder has to Contain: SRODecrypt.exe
  • The Folder has to Contain: XiaDecrypt.exe


How to use:
Drag the encrypted Skilldata file onto the XiaDecrypt.exe, then edit it, and Drop it on there again.
Caution: DO NOT Mix TXT Files! Edit one after the other. And always make a backup.

With that said, No hex for custom stuff anymore, easy peasy ;) have fun ;)


Download: [Only registered and activated users can see links. Click Here To Register...]

Source:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <string.h>
#include <io.h>

wchar_t encMark[] = L"//encrypt";

int main(int argc, char **argv) {
    wchar_t fileEncMark[9];
    FILE *in = NULL, *ads = NULL, *out = NULL;
    int i = 0;
    unsigned char isEncrypted = 0, encAfterOperation = 0;
    char fileHeader[26];
    char adsPath[MAX_PATH + 11];
    int retval = 0;


    if(argc < 2) {
        printf("Usage: %s <file1> <file2> ...\n", argv[0]);

        retval = 1;
        goto close;
    }

    for(i = 1; i < argc; i++) {
        if(!(in = fopen(argv[i], "r+b"))) {
            printf("Failed to open the file %s\n", argv[i]);
            printf("Skipping this file...\n");

            continue;
        }

        if(fseek(in, -18, SEEK_END)) {
            printf("Seek error(%s; 1)\n", argv[i]);
            printf("Skipping this file...\n");

            fclose(in);

            continue;
        }

        if(!fread(fileEncMark, 18, 1, in)) {
            printf("Read error(Failed to read from %s; 1)\n", argv[i]);
            printf("Skipping this file...\n");

            fclose(in);

            continue;
        }

        if(fseek(in, -26, SEEK_END)) {
            printf("Seek error(%s; 2)\n", argv[i]);
            printf("Skipping this file..\n");

            fclose(in);

            continue;
        }

        if(!fread(fileHeader, 26, 1, in)) {
            printf("Read error(Failed to read from %s; 2)\n", argv[i]);
            printf("Skipping this file...\n");

            fclose(in);

            continue;
        }

        strcpy(adsPath, argv[i]);
        strcat(adsPath, ":");
        strcat(adsPath, "fileHeader");

        if(!(ads = fopen(adsPath, "r+b"))) {
            if(!(ads = fopen(adsPath, "w+b"))) {
                printf("Critical error: Failed to create ADS\n");
                printf("You must use NTFS in order to use this program!!\n");

                fclose(in);

                retval = 3;
                goto close;
            }

            if(!wcsncmp(encMark, fileEncMark, 9)) {
                isEncrypted = 1;
                encAfterOperation = 0;
            } else {
                encAfterOperation = 1;
            }

        } else {

            if(!fread(&isEncrypted, 1, 1, ads)) {
                printf("Failed to read from ADS(%s; 1)\n", argv[i]);
                printf("Skipping this file...\n");

                fclose(in);
                fclose(ads);

                continue;
            }

            if(!fread(fileHeader, 26, 1, ads)) {
                printf("Failed to read from ADS(%s; 2)\n", argv[i]);
                printf("Skipping this file...\n");

                fclose(in);
                fclose(ads);

                continue;
            }

            if(isEncrypted) {
                encAfterOperation = 0;
            } else {
                encAfterOperation = 1;
            }
        }

        fclose(ads);

        if(fseek(in, 0, SEEK_END)) {
            printf("Seek error(%s; 3)\n", argv[i]);
            printf("Skipping this file...\n");

            fclose(in);

            continue;
        }

        if(!encAfterOperation) {
            if(_chsize(_fileno(in), ftell(in) - 26)) {
                printf("Failed to change the size of the file(%s; 1)\n", argv[i]);
                printf("Skipping this file...\n");

                fclose(in);

                continue;
            }
        }

        fclose(in);

        if(_spawnl(_P_WAIT, "SRODecrypt.exe", "SRODecrypt.exe", argv[i], NULL) == -1) {
            printf("Failed to start SRODecrypt.exe\n");
            printf("Make sure that both programs are in the same folder!\n");

            retval = 4;
            goto close;
        }

        if(!(ads = fopen(adsPath, "w+b"))) {
            printf("Failed to create the ADS(%s; ADS; 2)!!\n", argv[i]);
            printf("You won't be able to encrypt this file!\n");

            continue;
        }

        if(!fwrite(&encAfterOperation, 1, 1, ads)) {
            printf("Write error(%s; ADS; 7)\n", argv[i]);
            printf("You may have problems encrypting the file!\n");
        }

        if(!fwrite(fileHeader, 26, 1, ads)) {
            printf("Write error(%s; ADS; 9)\n", argv[i]);
            printf("You may have problems encrypting the file!\n");
        }

        fclose(ads);

        if(encAfterOperation) {
            if(!(out = fopen(argv[i], "ab"))) {
                printf("Failed to open the file %s\n", argv[i]);
                printf("The file is now missing the last 26 bytes!!\n");

                retval = 5;
                goto close;
            }

            if(!fwrite(fileHeader, 26, 1, out)) {
                printf("Write error(%s; 10)\n", argv[i]);
                printf("The file is now missing some bytes at the end!!\n");

                fclose(out);

                retval = 6;
                goto close;
            }

            fclose(out);
        }
    }

    printf("Done!\n");

close:
    printf("Press ENTER to close the program...\n");
    getchar();

    return retval;
}
02/06/2012 10:47 evolution007#2
code looks intresting! thanks for release
02/06/2012 15:33 18andLife#3
Thanks a lot, really useful. I couldn't add SRO-R skills though, my client crash for some reason.
02/06/2012 15:49 •ᵔBeGodOfWarᵔ•#4
Thanks for release this ver :)
02/06/2012 17:04 18andLife#5
Something is wrong with this... Even if I just decrypt it, then encrypt the file without editing it and import to my pk2, my client won't start at all.

Edit: nvm, got it to work. Had to use hex editor though.
02/06/2012 21:06 ~Nicole#6
Weird, tested it on 4 machines and it worked just fine, anyways, im still glad it helped some people :)
02/07/2012 09:07 jumalauta#7
Quote:
Originally Posted by ~Nicole View Post
Weird, tested it on 4 machines and it worked just fine, anyways, im still glad it helped some people :)
Back to the scene eh? Long time no see.. :cool:
09/03/2012 05:28 thegfx3r#8
Sorry to bump the thread but I need to know, is the file Skilldata.txt or Skilldataenc.txt
09/03/2012 05:37 PortalDark#9
#moved to correct section