Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <Wincrypt.h>
- #ifdef _MSC_VER
- #pragma warning( push )
- #pragma warning( disable : 4996 )
- #endif
- #define NBYTE(x) (*((BYTE*)&(x)))
- static const BYTE pKey[8] = {0xFF, 0x41, 0x54, 0x73, 0x84, 0x9A, 0xC8, 0xA6};
- int nDecryptBlock(HCRYPTKEY hKey, unsigned char* pBuffer)
- {
- signed int i = 0;
- int dwCheck;
- int result;
- DWORD dwBlockSize = 8;
- CryptDecrypt(hKey, 0, 1, 0, (BYTE *)pBuffer + i, &dwBlockSize);
- i = 0;
- do
- {
- NBYTE(dwCheck) = *(BYTE *)(i + pBuffer);
- if ((BYTE)dwCheck == 0x7F)
- {
- result = 0;
- }
- else if ((BYTE)dwCheck == 0x80u)
- {
- result = 0xFF;
- }
- else
- {
- dwCheck = (unsigned __int8)dwCheck;
- if ((unsigned __int8)dwCheck >= 0x80u)
- result = dwCheck - 1;
- else
- result = dwCheck + 1;
- }
- *(BYTE *)(i++ + pBuffer) = result;
- }
- while ( i < 8 );
- *(DWORD *)pBuffer ^= 0xA4A7FF88;
- *(DWORD *)(pBuffer + 4) ^= 0xA0447823;
- return result;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- if(argc != 3)
- {
- printf("Echo of Soul Files Decryptor\n");
- printf("(c) 2015 / Ekey (h4x0r) / v0.1a\n\n");
- printf("[Usage]\n");
- printf("\tEOSDecryptor <pScrFile> <pDstFile>\n");
- printf("[Examples]\n");
- printf("\tEOSDecryptor EOS.ini EOS.ini.dec\n\n");
- return -1;
- }
- FILE * fi = fopen(argv[1], "rb");
- FILE * fo = fopen(argv[2], "wb");
- if (fi == NULL)
- {
- printf("[ERROR]: Can't open file %s\n", argv[1]);
- return -1;
- }
- if (fo == NULL)
- {
- printf("[ERROR]: Can't write output file %s\n", argv[2]);
- return -1;
- }
- fseek(fi, 0, SEEK_END);
- size_t dwSize = ftell(fi);
- fseek(fi, 0, SEEK_SET);
- dwSize -= 4;
- fseek(fi, 4, SEEK_SET);
- unsigned char *pBuffer = new unsigned char[dwSize];
- memset(pBuffer, 0, dwSize);
- fread((char*)pBuffer, dwSize, 1, fi);
- HCRYPTPROV hCryptProv = 0;
- HCRYPTKEY hKey = 0;
- HCRYPTHASH hHash = 0;
- if (!CryptAcquireContextW(&hCryptProv, L"SBENCRYPTIONKEYCONTAINER10", L"Microsoft Enhanced Cryptographic Provider v1.0", 1u, 0) && GetLastError() == 0x80090016)
- CryptAcquireContextW(&hCryptProv, L"SBENCRYPTIONKEYCONTAINER10", 0, 1u, 8u);
- CryptCreateHash(hCryptProv, 0x8003u, 0, 0, &hHash);
- CryptHashData(hHash, pKey, 8u, 0);
- CryptDeriveKey(hCryptProv, 0x6801u, hHash, 0x800000, &hKey);
- int i = 0;
- int dwBlocks = dwSize >> 3;
- do
- {
- nDecryptBlock(hKey, pBuffer + i);
- i += 8;
- --dwBlocks;
- }
- while (dwBlocks);
- fwrite(pBuffer, dwSize, 1, fo);
- fclose(fi);
- fclose(fo);
- printf("Done!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement