Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 02:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ RC5 Decrypt/Encrypt

Discussion on C++ RC5 Decrypt/Encrypt within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Mr_PoP's Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
C++ RC5 Decrypt/Encrypt

Greetings guys,

i was working on my own server and am coding it in c++, i heared i must decrypt the msg from the client so i can check if the user is exist or not (geting server name,account id and password) for patch 5290 or more

so i was wondering if someone can help me and correct what am doing wrong here is my code hopefully someone can help me

RC5.h
Code:
#ifndef	RC5_H
#define RC5_H

#define	RC5_32			32

#define	RC5_12			12
#define	RC5_SUB			(RC5_12*2 + 2)

#define	RC5_16			16
#define	RC5_KEY			(RC5_16/4)

const unsigned long	RC5_PW32	= 0xB7E15163;
const unsigned long	RC5_QW32	= 0x61C88647;

const unsigned char RC5PASSWORD_KEY[16] = {	0x3C, 0xDC, 0xFE, 0xE8, 0xC4, 0x54, 0xD6, 0x7E, 
											0x16, 0xA6, 0xF8, 0x1A, 0xE8, 0xD0, 0x38, 0xBE };
const unsigned char RC5BARPASSWORD_KEY[16] = {	0x44, 0xD0, 0xE2, 0xBA, 0x4A, 0x38, 0x14, 0x44, 
												0x64, 0xE0, 0x12, 0xAE, 0xDA, 0x56, 0x1C, 0xF8 };

////////////////////////////////////////////////////////////////////////////////////////////////

class	CRc5
{
public:
	void Rc5InitKey(const unsigned char bufKey[RC5_16]);
	void Rc5Encrypt(void* buf, int nLen8);
	void CRc5::Rc5Decrypt(void* buf, int nLen8);

protected:
	unsigned long	m_bufKey[RC5_KEY];
	unsigned long	m_bufSub[RC5_SUB];
};

#endif // RC5_H
RC5.cpp
Code:
#include <string>
#include <assert.h>

#include "RC5.h"


unsigned long	rotate_left(unsigned long nData, unsigned long nCount);
unsigned long	rotate_right(unsigned long nData, unsigned long nCount);

void CRc5::Rc5InitKey(const unsigned char bufKey[RC5_16])
{
	try{
		memcpy(m_bufKey, bufKey, RC5_16);
	}catch(...) {
#ifdef	_DEBUG
		assert(!"InitRc5Key()");
#endif
	}
	/*for (int i = 0; i < 4; i++)
    m_bufKey[i] = (long)(bufKey[i * 4] + (bufKey[i * 4 + 1] << 8) + (bufKey[i * 4 + 2] << 16) + (bufKey[i * 4 + 3] << 24));
    m_bufSub[0] = RC5_PW32;*/
	m_bufSub[0] = RC5_PW32;
	for(int i = 1; i<26; i++)
	{
		m_bufSub[i] = m_bufSub[i-1] - RC5_QW32;
	}
	int				i, j;
	unsigned long	x, y;
	i = j = x = y = 0;
	for(int k = 0; k <=78; k++)
	{
		m_bufSub[i] = rotate_left((m_bufSub[i] + x + y), 3);
		x = m_bufSub[i];
		i = (i + 1) % 0x1A;
		m_bufKey[j] = rotate_left((m_bufKey[j] + x + y), (x + y));
		y = m_bufKey[j];
		j = (j + 1) % 4;
	}
}


void CRc5::Rc5Encrypt(void* buf, int nLen8)
{
	assert(nLen8 % 8 == 0);
	nLen8 = (nLen8/8) * 8;
	if(nLen8 <= 0)
		return;

	unsigned long* bufData = (unsigned long*)buf;
	for(int k = 0; k < nLen8/8; k++)
	{
		unsigned long	a = bufData[2*k];
		unsigned long	b = bufData[2*k + 1];

		unsigned long	le	= a + m_bufSub[0];
		unsigned long	re	= b + m_bufSub[1];
		for(int i = 1; i <= 12; i++)
		{
			le = rotate_left((le ^ re), re) + m_bufSub[2*i];
			re = rotate_left((re ^ le), le) + m_bufSub[2*i + 1];
		}

		bufData[2*k]		= le;
		bufData[2*k + 1]	= re;
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////
void CRc5::Rc5Decrypt(void* buf, int nLen8)
{
	assert(nLen8 % 8 == 0);
	nLen8 = (nLen8/8) * 8;
	if(nLen8 <= 0)
		return;

	unsigned long* bufData = (unsigned long*)buf;
	for(int k = 0; k < nLen8/8; k++)
	{
		unsigned long	ld	= bufData[2*k];
		unsigned long	rd	= bufData[2*k + 1];
		for(int i = 12; i >= 1; i--)
		{
			rd = rotate_right((rd - m_bufSub[2*i + 1]),  ld) ^ ld;
			ld = rotate_right((ld - m_bufSub[2*i]),  rd) ^ rd;
		}

		unsigned long	b = rd - m_bufSub[1];
		unsigned long	a = ld - m_bufSub[0];

		bufData[2*k]		= a;
		bufData[2*k + 1]	= b;
	}
}



unsigned long	rotate_left(unsigned long nData, unsigned long nCount)
{
	 return (nData << (nCount & 0x1F) | nData >> 0x20 - (nCount & 0x1F));
}

////////////////////////////////////////////////////////////////////////////////////////////////
unsigned long	rotate_right(unsigned long nData, unsigned long nCount)
{
	return (nData << (nCount & 0x1F) | nData >> 0x20 - (nCount & 0x1F));
}
so please if am doing something wrong tell me thnx
Mr_PoP is offline  
Old 02/10/2011, 01:09   #2
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
Quote:
Originally Posted by Mr_PoP View Post
here is my code
That's not your code. It's clearly a copy/paste from the EO source.
nTL3fTy is offline  
Old 02/10/2011, 01:19   #3
 
Mr_PoP's Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
Quote:
Originally Posted by nTL3fTy View Post
That's not your code. It's clearly a copy/paste from the EO source.

EO source -.-" i nvr saw it , it's a code from an old account server lawl and i edit some stuff into it , i nver said that i made it did I!?

Edit: here is my code means the code am working on -.-" , or should i say (here is a code i found it in an old account server so i edit it and am trying to make it work ) DUH!
Edit: if u dont mind can u send me link to that source maybe i can get something from it. Thnx
Mr_PoP is offline  
Reply


Similar Threads Similar Threads
Encrypt/Decrypt
09/01/2010 - EO PServer Hosting - 9 Replies
Who can tell me how can i decrypt a password mage by the register page?:D
Encrypt/Decrypt Function
10/03/2009 - CO2 Programming - 12 Replies
I think I've found the wrapper for send() at 00536FDB but I cannot find any calls just before the actual winsock send that would encrypt data. Am I looking in the wrong place?
(Request) DeCrypt / Encrypt
05/04/2009 - RF Online - 6 Replies
Do you have any DeCrypt/Encrypt program what works for Item.edf in RFOph ? Thanks. :D
encrypt/decrypt guide .INI
12/01/2007 - Archlord - 4 Replies
I put this little guide together to make it more understandable and easier to read, this is in regards to the other guys post (menasculio) who posted the source code/compiled Put that file in the INI folder of archlord. start>run>CMD type in CD C:\Program Files\Codemasters\Archlord\ini once you have done that you can rename the .exe you downloaded to a shorter name, i named mine DEC.
Itemtype.DAT Encrypt/Decrypt
06/07/2007 - CO2 Exploits, Hacks & Tools - 1 Replies
I don't know who made this tool i found it in my C:&#092; folder named Project1.exe it has no company name nor does it have an about section. So i cannot take credit for this tool. It Encrypts and Decrypts the itemtype.dat file with a few clicks of the mouse, without having to be in the Conquer 2.0&#092;ini folder unlike the DeEn tool that was used for decrypting the Monster.dat. This tool should work for the Monster.dat file too. Just found it on my comp and thought i'd share it since its a bit...



All times are GMT +1. The time now is 02:23.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.