Mazey Flyff Decrypt

09/20/2014 15:44 WurstbrotQT#1
It's me again, there might be good stuff in that client, idk, have fun.

Code:
#include "stdafx.h"
#include "Mazey Decrypt.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object
/*	Author		WurstbrotQT
 *	Purpose		Disassemble Mazey File Format
 *	Date		19/09/2014
 */

CWinApp theApp;

using namespace std;

unsigned int DecryptFile(CString&);
unsigned int DecryptMazey(CString const);
BYTE Decrypt(BYTE, BYTE);

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	HMODULE hModule = ::GetModuleHandle(NULL);

	if (hModule != NULL)
	{
		// initialize MFC and print and error on failure
		if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
		{
			// TODO: change error code to suit your needs
			_tprintf(_T("Fatal Error: MFC initialization failed\n"));
			nRetCode = 1;
		}
		else
		{
			CreateDirectory(TEXT("Decryption"), NULL);
			cout << "Decrypting..." << endl;
			DWORD dwTickStart = GetTickCount();
			unsigned int nDecryptedFileCount = DecryptMazey(TEXT(""));
			cout << "Decrypted " << nDecryptedFileCount << " files in " << (GetTickCount() - dwTickStart) << "ms";

			getchar();
		}
	}
	else
	{
		// TODO: change error code to suit your needs
		_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
		nRetCode = 1;
	}

	return nRetCode;
}


unsigned int DecryptMazey(const CString argPath)
{
	CString sPathToSearch = argPath + TEXT("*.*"); // we cannot simply look for .res files since subdirectories wouldn't be included
	WIN32_FIND_DATA winData;
	HANDLE hSearch = FindFirstFile(sPathToSearch, &winData);

	if (FAILED(hSearch))
		return 0;

	unsigned int nRet = 0;

	do {
		CString sFileName = winData.cFileName;
		if (winData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if (!!sFileName.Compare(TEXT(".")) && !!sFileName.Compare(TEXT(".."))){
				CString sNewPath;
				sNewPath.Format(TEXT("%s%s\\"), argPath, sFileName);
				nRet += DecryptMazey(sNewPath);
			}
		}
		else // file
		{
			int nNameLength = sFileName.GetLength();
			if (nNameLength >= 4){
				CString sExt = sFileName.Mid(nNameLength - 4);
				if (!sExt.Compare(TEXT(".res"))) {
					nRet += DecryptFile(argPath + sFileName);
				}
			}
		}
	} while (FindNextFile(hSearch, &winData));
	FindClose(hSearch);

	return nRet;
}

BYTE Decrypt(BYTE argValue, BYTE argKey)
{
	argValue = ~argValue ^ argKey;
	return (argValue << 4) | (argValue >> 4);
}

unsigned int DecryptFile(CString & argName)
{
	CFile fRead;
	if (FALSE == fRead.Open(argName, CFile::modeRead | CFile::shareExclusive))
		return 0;
	bool bEncryption;
	BYTE byEncryptionKey;
	int nHeaderSize;
	BYTE *pData;
	// we never assume negative file counts
	unsigned short nFileCount;
	unsigned int nRet = 0;
	int nRemainder = 7; // skip version

	CString sFileNameToLower = argName.MakeLower();
	bool bSkipTime = !sFileNameToLower.Compare(TEXT("maze.res")) ||
					 !sFileNameToLower.Compare(TEXT("maze1.res")) ||
					 !sFileNameToLower.Compare(TEXT("world\\wdquiz\\wdquiz.res")) ||
					 !sFileNameToLower.Compare(TEXT("world\\wdquiz\\wdquiz1.res")) ||
					 !sFileNameToLower.Compare(TEXT("world\\wdmarket\\wdmarket.res")) ||
					 !sFileNameToLower.Compare(TEXT("model\\indigo.res")) ||
					 !sFileNameToLower.Compare(TEXT("model\\texture\\indigo.res"));

	fRead.Read(&byEncryptionKey, sizeof(BYTE));
	fRead.Read(&bEncryption, sizeof(bool));
	fRead.Read(&nHeaderSize, sizeof(int));

	pData = new BYTE[nHeaderSize];
	fRead.Read(&pData[0], nHeaderSize);

	// decrypt the header as every flyff client
	for (int i = 0; i < nHeaderSize; ++i)
		pData[i] = Decrypt(pData[i], byEncryptionKey);

	memcpy_s(&nFileCount, sizeof(short), &pData[nRemainder], sizeof(short));
	nRemainder += 2;

	// we have to go thru the lot
	for (short nCurFile = 0; nCurFile < nFileCount; ++nCurFile)
	{
		unsigned short nFileNameLength;
		char szFileName[_MAX_FNAME];
		int nOffset;
		int nFileSize;

		memcpy_s(&nFileNameLength, sizeof(short), &pData[nRemainder], sizeof(short));
		nRemainder += sizeof(short);
		ASSERT(nFileNameLength < _MAX_FNAME);
		memcpy_s(szFileName, nFileNameLength, &pData[nRemainder], nFileNameLength);
		szFileName[nFileNameLength] = 0;
		nRemainder += nFileNameLength;
		
		memcpy_s(&nFileSize, sizeof(int), &pData[nRemainder], sizeof(int));
		nRemainder += sizeof(int);

		// some files skip the last edit time, which is rubbish, but here we go
		if ( !bSkipTime )
			nRemainder += sizeof(int); // we don't need that parameter anyway, so skip as well.

		// the last interesting parameter, the file offset itself
		memcpy_s(&nOffset, sizeof(int), &pData[nRemainder], sizeof(int));
		nRemainder += sizeof(int);

		// directly write content to file
		CFile fWrite;
		CString sNewFileName = TEXT("Decryption\\");
		sNewFileName += szFileName;

		if (TRUE == fWrite.Open(sNewFileName, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive))
		{
			BYTE *pContent = new BYTE[nFileSize];
			fRead.Seek(nOffset, CFile::begin);
			fRead.Read(pContent, nFileSize);
			if ( bEncryption )
				for (int i = 0; i < nFileSize; ++i)
					pContent[i] = Decrypt(pContent[i], byEncryptionKey);

			fWrite.Write(pContent, nFileSize);
			fWrite.Close();
			delete[] pContent;
			nRet++;
		}
	}
	// free unused memory
	delete[] pData;

	return nRet;
}
Proof:
[Only registered and activated users can see links. Click Here To Register...]
09/20/2014 17:02 Sanctuary'#2
Könntest du vielleicht freundlicherweise auch den Decrypter selbst hochladen? :)
09/20/2014 17:15 ™Dryad#3
Da ich noch net so viel erfahrung in Vs habe,wollte ich gern ma wissen wie man sone exe überhaupt erstellt ?..
09/20/2014 17:21 AsuraDeveloper#4
Empty project copy paste build..

@wurst youre cancerous bad in programming zz
09/20/2014 17:39 WurstbrotQT#5
Quote:
Originally Posted by AsuraDeveloper View Post
Empty project copy paste build..

@wurst youre cancerous bad in programming zz
Thank you very much, please share your points of concern so that I'm able to be as good as you, I'd really appreciate that :handsdown::handsdown:

Quote:
Originally Posted by ™Ep!sch View Post
Da ich noch net so viel erfahrung in Vs habe,wollte ich gern ma wissen wie man sone exe überhaupt erstellet ?..
Komplettes Projekt ist im Anhang.
09/20/2014 17:53 ™Dryad#6
Danke dir :)

Aber mit vs2003 bekomm ich das net geöffnet o.O
Lade mir grade vs 2012 runter vllt geht es ja damit :)
09/20/2014 17:57 Sanctuary'#7
Quote:
Originally Posted by ™Ep!sch View Post
Danke dir :)

Aber mit vs2003 bekomm ich das net geöffnet o.O
Lade mir grade vs 2012 runter vllt geht es ja damit :)
ich glaube das wird auch nichts bringen.
Er hat es mit vs2013 compilt da ich es ohne eine Warnung mit vs2013 öffnen könnte.. wäre es 2012 würde da stehen das es mit einer früheren Version erstellt wurde.
09/22/2014 03:30 rosemie1#8
Release the Mazey Red Perin Source pleasee..
09/22/2014 14:12 Rhyder`#9
Quote:
Originally Posted by rosemie1 View Post
Release the Mazey Red Perin Source pleasee..
it was an decryption of the client so there is nothing in part of the resource to be ripe there :D
09/22/2014 14:29 rosemie1#10
Quote:
Originally Posted by jayjei14 View Post
it was an decryption of the client so there is nothing in part of the resource to be ripe there :D
Jay, Can you repost your Country System?
Your Image there is missing..
Can't follow the SQL thing :3
09/23/2014 08:46 Rhyder`#11
Quote:
Originally Posted by rosemie1 View Post
Jay, Can you repost your Country System?
Your Image there is missing..
Can't follow the SQL thing :3
it is easy to follow. just add atleast ", 0" below the other zero's
09/25/2014 22:46 InControl2#12
hey how to use this Decrypt? :l
09/26/2014 07:05 Sanctuary'#13
Quote:
Originally Posted by AsuraDeveloper View Post
Empty project copy paste build..
u need vs2013 i think
09/26/2014 08:06 AsuraDeveloper#14
Quote:
Originally Posted by Sanctuary' View Post
u need vs2013 i think
Are you freaking high? I know how to compile. I just gave you instructions on how to do it cause epvp kids seem 2 be that stupid.

Wouldnt use some released shit anyway, especially not by some smacktard coder called ''Pumaaa'' who had the biggest exploit in his system ever.
09/26/2014 08:19 Sanctuary'#15
Quote:
Originally Posted by AsuraDeveloper View Post
Are you freaking high? I know how to compile. I just gave you instructions on how to do it cause epvp kids seem 2 be that stupid.

Wouldnt use some released shit anyway, especially not by some smacktard coder called ''Pumaaa'' who had the biggest exploit in his system ever.
think a bit of your answer ..

Because i just answered it for InControl2 with your Words ..

and the few words "u need vs2013 i think" was also for InControl2

and btw
WurstbrotQT isn't called Pumaaa .. he is Pumbaaa
Excuse me if I'm wrong but thats what i heard